Is there any way to add a sidebar depending on the content of the node? For example, if the node content contains the string ".pdf" it turns on a sidebar block which tells people they can get Reader from the adobe website?

Is it possible using some cleverly crafted php in the page visibility options of the block?

Cheers,
t42

Comments

Mark Theunissen’s picture

Yeah, I guess that would be possible..

You'd have to do something like this:


$node = node_load(arg(1));

return stristr($node->body, '.pdf', TRUE);

Hope that helps!

__________________________________________________________

Mark Theunissen

Code Baboon
Drupal based services

t42’s picture

For some reason it doesn't like that TRUE on the stristr. Remove that and it works like a charm!

It produces interesting error messages on admin pages, but I can probably work those out myself.

Thanks Mark!

Mark Theunissen’s picture

No problem! I just typed that code without any form of testing at all, so yeah there is probably a bit of work to do on it before it works properly! ;)

__________________________________________________________

Mark Theunissen

Code Baboon
Drupal based services

Mark Theunissen’s picture

You may also want to do some sanity checks, make sure that the path is /node/xxx


if ((arg(0) == 'node') && (is_numeric(arg(1))

__________________________________________________________

Mark Theunissen

Code Baboon
Drupal based services

nijuley’s picture

Explore Side Content module
http://drupal.org/project/sidecontent