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.

0

2 Answers 2

2

In the visibility textarea of your block, select PHP code and put the following:

<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && (arg(2) == '' || arg(2) == 'view')) {
  return TRUE;
} else {
  return FALSE;
}
?>
1
  • Exactly what I was looking for, this even works with taxonomy! Perfect! Thanks so much.
    – Kyle
    Commented Dec 20, 2011 at 18:48
0

If you really want you can simply add node/1 and node/1/view to the visibility list. However this is not the Drupal way imho - Drupal expects that default local tasks aren't explicitly specified in the URL (and this is why for example it outputs node URLs as node/1 and not node/1/view in the first place). Path based rules like this can make a system more brittle - and doing it in a way that doesn't fit in with existing Drupal behaviour is asking for trouble imho. What is it you're trying to do?

3
  • 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. Each node will act as a users own personal page and needs to have a block shown only on the main page of it (both node/1/view and node/1, but there will be thousands of nodes with this same setup). Hope that clears it up.
    – Kyle
    Commented Dec 20, 2011 at 15:25
  • @Piontek Media So the problem is how to have the block display on some nodes and not others?
    – Andy
    Commented Dec 20, 2011 at 16:15
  • Not quite, the problem is how to have the block display on all nodes front page, and only the front page.
    – Kyle
    Commented Dec 20, 2011 at 16:32

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.