By drupalworld on
Hello there,
I am not a programmer and I don't know about about php.
However I found a code that works very well for content type ( Thank you Vincent)
<?php
$match = FALSE;
$types = array('YOUR CONTENT TYPE HERE' => 1);
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
$type = $node->type;
if (isset($types[$type])) {
$match = TRUE;
}
}
return $match;
?>
You can even add several separate node to this content type:
<?php
$match = FALSE;
$types = array('YOUR CONTENT TYPE HERE' => 1);
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
$type = $node->type;
if (isset($types[$type])) {
$match = TRUE;
}
}
if (substr($_SERVER["REQUEST_URI"], 0) == "/YOUR NODE HERE")
{ $match = TRUE;}
if (substr($_SERVER["REQUEST_URI"], 0) == "/ANOTHER NODE HERE")
{ $match = TRUE;}
return $match;
?>
My question:
I am using the "Bonus: Summary + full view, which is great to set up a directory.
The problem is that I end up with loads of view pages which of course do not belong to my content type.
How can I have a block which is visible for all nodes of my content type AND on the view pages??
Of course I can add every single view page using the method I included above.. but there must be a shorter way, no?
Many thanks,
Drupalworld
Comments
Content type + taxonomy term
Or another to do it, I just realized, without the views would be to have a php for content type AND taxonomy term...
Is this possible?
Many thanks,
Drupalworld
Might be too late but...
if it's not too late to change the urls of your site, and if it makes sense to the info-architecture, you could use pathauto to give all nodes of a given type a similar url and give the relevent views the same url pattern:
for example, say your type is news items, you could make the urls for all the nodes be:
and the view (or views) be:
or similar.
Then show the block only on:
Not sure if this is what you were asking though.
R
------------------------------------
Gorton Studios - Websites that Work. http://www.gortonstudios.com/
http://www.gortonstudios.com/portfolio/technologies/drupal
------------------------------------
Ronan
Founder - NodeSquirrel - https://www.nodesquirrel.com/
Agency Tools Lead - Pantheon - https://www.pantheon.io/
Great tip
Thank you so much... I would have never looked into that direction without your help.
Drupalworld
What an excelent solution,
What an excelent solution, solved a problem i had been looking at for a while , using the second code example.
But, there is always a but ! How would I impliment a wildcard into this
I have a URL that generates variants on the folowing
I tried using the normal syntax for block visibility as follows but without success
Can anyone suggest a solution?