0

How can I check for a specific directory in my URL? I need to display an image if I'm in http://www.mywebsite.com/displayimg/mypage but not if I'm in http://www.mywebsite.com/mypage... would it be something involving drupal_get_path?

4
  • What you exactly want to do ? please explain in a better way Commented Sep 19, 2014 at 9:46
  • 1
    what are 'displayimag' and 'mypage'? are they strings or ids? what? Commented Sep 19, 2014 at 9:46
  • displayimg is a directory in my website. If the page points to it, I need to find a way to get the info from the URL and instruct Drupal to display a particular img on my page (mypage).
    – Jane
    Commented Sep 19, 2014 at 9:48
  • Ok, you can do it by checking arg from the URL. see arg Commented Sep 19, 2014 at 9:51

2 Answers 2

1

You can use arg to check for URL arguments. In your case, the second argument has to be empty, so you can try something like this:

if (arg(0) == 'displayimg' && arg(1) == 'mypage') {
  // Do something meaningful.
}
0
1

Better to use block to display image. Use block visibility setting for displaying on specific URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.