Hi,
How do I add a php condition on a block so that it only shows for a certain node type but is hidden for all others.
(eg the php/drupal translation of "show if node type == blog").
I have an half answer, I'm gone to my block configuration:
admin/build/block/configure/block/numberofblock
and then I'm gone to this section:
Page specific visibility settings - Show block on specific pages:
and I left checked the checkbox:
Show if the following PHP code returns TRUE (PHP-mode, experts only).
I was just having this code working well with azienda node:
<?php
if ((arg(0) == 'node') && is_numeric(arg(1)) && (! arg(2))) {
$node = node_load(arg(1));
return ($node->type == 'azienda');
}
return FALSE;
?>
then i have changed this line of code:
return ($node->type == 'azienda');
into this:
return ($node->type == 'azienda', 'gallery');
getting this code:
<?php
if ((arg(0) == 'node') && is_numeric(arg(1)) && (! arg(2))) {
$node = node_load(arg(1));
return ($node->type == 'azienda', 'gallery');
}
return FALSE;
?>
But now this PHP code returns always TRUE, instead I need that it became true only for azienda and gallery node.
Then I tryed also with this script, but it don't work, also don't show #
if ((arg(0) == 'node') && is_numeric(arg(1)) && (! arg(2))) {
$node = node_load(arg(1));
print"#";
print_r($node->type);
print"#";
return (($node->type == 'azienda') ||
($node->type == 'image')
);
}
return FALSE;
Comments
I like using <?php$types =
I like using
Try this. <?phpif ((arg(0) ==
Try this.
//Edited..
The above nevets code is a better way..
Wow, ye this is perfectly
Wow, ye this is perfectly working: (I just changed gallery with image because it was one my mistake first)
so now It is showed on both nodes, IMAGE:
http://www.forniture-alberghiere.net/image/gmsediecom-10a10
http://www.forniture-alberghiere.net/image/gmsediecom-10a10?size=_original
http://www.forniture-alberghiere.net/image/gmsediecom-10a10?size=thumbnail
and on node AZIENDA:
http://www.forniture-alberghiere.net/gm-grottoli-massimo
(you can check it from link named "Chiedi informazioni" (in english it mean ask informations) going to http://www.forniture-alberghiere.net/webform/chiedi-maggiori-informazioni)
But it is not showed into my site www.gmsedie.com, for example:
http://www.gmsedie.com/image/gmsediecom-10a10?size=thumbnail
this domain is managed trough DOMAIN ACCESS module, how I can show this block or its clone also on this site and others in future?
Mmm it look just strange that this module was just installed and well configured to show block on www.gmsedie.com : http://drupal.org/project/domain_blocks but it not appear.
I was also writing on domain
I was also writing on domain block issues http://drupal.org/node/627066 .
It look that the problem is solved, the script is ok, just needing to add th same block also on different theme, because gmsedie.com was using a differnt theme.