By marknt15 on
Hi Guys,
How can I control a block's visibility depending on the current module or URL. I have an ed-classifieds module.
If I click the Classifieds Link located in the primary menu then I want a block in the sidebar to appear. Then, in any other URL aside from ed-classified, my block will always be invisible.
Can someone please tell me a tutorial link or some PHP code to work on? Thanks :)
Cheers,
Mark
Comments
change the 'Page specific
change the 'Page specific visibility settings' at the bottom of the block's configuration page.
if your site can use a URL structure where your Classifieds are at e.g. http://example.com/ed-classified/ad-title and other URLs do not start with http://example.com/ed-classified , then you can just set the visibility settings to 'Show on only the listed pages' and set the 'Pages' to:
ed-classified
ed-classified/*
if the URLs won't follow a simple pattern like that, you'll need a PHP snippet (and you'd need more to supply more info about how you're differentiating the classifieds from other site content to get specific suggestions for that).
Thanks
Thanks arh1. I was checking about that setting but I didn't know what will I put to the Pages: textarea. Now it works. Thanks again. :)
Problem about secondary links....
Hi arh1,
I have a follow up question. How can I hide the secondary menus based on a given URL? For example I want my secondary menu to only appear when I am browsing the ed-classifieds? Other than that, my secondary menu will always be hidden.
Is there a setting like a 'Page specific visibility settings' in the secondary menu?
Thanks in advance :)
if you are printing the
if you are printing the secondary links using the block (automatically) provided by the menu module, you can use the same interface as discussed above. if your theme is printing them directly, you'll need to add some custom logic via PHP...
something like this in template.php:
and something like this in page.tpl.php (lifted/tweaked from Zen):
Thanks again it worked! :)
Thanks again arh1 :D
Through your help and this link: http://drupal.org/node/134425
I solved my problem. I'm new a newbie in drupal and I will straighten up each learning curve hehe (^__ _^)Y
This is my code.