By pacesie on
I would like to make a block visible only when the node is a blog article ( or forum article etc ). I reason that some php code in the { admin | block | Page specific visibility settings } should do the work. I am a drupal and php newbie and do not know where to start. Could someone provide a code snippet for that? Thanks!
Comments
visability options
I've always used pathauto module and clean urls so accomplish the task like so..
In the block visability options, select 'Show on only the listed pages.' and then in the box below
have
blog/*
the asterix acts as a wild card so the block will show on all pages where the path is http://yoursite.com/blog/...whatever...
there is probably some php code that does the same thing but being a newbie myself this is the easier approcah IMO.
Stuart Mackenzie
http://rojojam.com
The more general answer
First you need to determine if you are on a page displaying a single node then what the node type is
break;
Thanks for this. Just for the next person... include a "break;" at the end of each case for the code to work.
Or not
In the example code, there is no break on purpose. This allows us to handle multiple types in the same way, without the break, the earlier case statement 'falls into' the next case statement.
Thanks! I implemented this to
Thanks! I implemented this to only display a block on content type of 'product'. I did, however, need the break in the case statement after returning TRUE. For some reason my block would still display in places where I didn't want it to, even after the return statement. I tried clearing the cache, browser cache, etc.