0

I have a block that I need displayed only on the main page of a node.

I can get it to display on node/1/view by putting node//view in the conditions, but that only works if view is in the URL. I want it to show whether I go to node/1/view or node/1, but NOTHING else. If I try node/ it shows it for every node page, not just node/1. I also tried node/*/ but that didn't work at all as it appears the ending slash is being removed.

1
  • I think I'm missing something here... what are you calling the "main page of a node"?
    – Malks
    Dec 20, 2011 at 22:25

3 Answers 3

1

In that case you need to to have node/*/view and node/* on separate lines.

Unless the node that users are customizing are a specific node type, then you should use the php code to check for a certain node type, regardless of node id or url.

2
  • I tried that, node/* adds it to every page in the node, not just the main one.
    – Kyle
    Dec 20, 2011 at 16:33
  • So the node id is not fixed, and the node that the user will be customizing is not a specific content type? Explain your whole scenario in as best detail as possible to we can answer correctly.
    – Bayo
    Dec 21, 2011 at 17:11
1

You could use the PHP method and do something like this:

<?php

$path=$_GET['q'];
$elements=explode('/',$path);
$count=count($elements);

if (($count==2 && $element[0]=='node' && is_numeric($elements[1]) ||
    ($count==3 && $element[0]=='node' && is_numeric($elements[1] && $element[2]=='view')) {
    return TRUE;
}

return FALSE;

?>

If you put this in the "Show block on specific pages/ Show if the following PHP code returns TRUE (PHP-mode, experts only)" part of the block admin page, you should be all set (barring any horrible typos or brainfades on my part :)

2
  • Although I would most certainly use the arg(0), arg(1) and arg(2) instead of an $elements variable and you're missing a few parenthesis in that example... but that's pretty much the only way because node/* will otherwise give you all the paths that start with node/... Dec 21, 2011 at 7:16
  • The arg() function does the $_GET explosion internally, so that's pretty much stylistic, but yes, I did miss a paren to close the second is_numeric() :)
    – Jimajamma
    Dec 21, 2011 at 8:16
0

I don't know if I've missed the point but you can enter multiple values in that field, one per line. So have node/1 and node/1/view on separate lines.

4
  • That's not going to work though, I need it to be automatic as users will be signing up and getting a node page to customize. There will be thousands of them, and more added every day.
    – Kyle
    Dec 20, 2011 at 14:06
  • The 1 in the above value is the userid?
    – Malks
    Dec 20, 2011 at 14:08
  • No, the 1 in the above code would be the node id.
    – Kyle
    Dec 20, 2011 at 15:19
  • users have a node reference to a particular node? What node page are they customising?
    – Malks
    Dec 20, 2011 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.