Question

I have a block that allows a site visitor to query an external calendar, but it will only work for certain nodes.

How can I set it up so that I can i) indicate whether or not a node has calendar data available for the node and ii) if it has calendar data available, display the block and if it hasn't got calendar data available, the block is not displayed?

Someone suggested to me that I use Workflow to do this, but I've not been able to figure out how Workflow would help me set this up.

Was it helpful?

Solution

I would use the PHP visibility settings to display the block on a node's page if a cck value in that node has some value, assuming that this cck field's value is an indication of that node containing calendar data. Once you've created the block that you want to display (or not display) add the following code to the "Page specific visibility settings" in the block configuration menu:

<?php 
$node = node_load( arg(1) );

if ($node && $node->type =="[your_content_type]" && $node->field_has_cal_data[0]['value'] =='Yes'){
return TRUE;
}

return FALSE;

?>

This is assuming that the url is built like "content/name-or-id-of-node".

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top