1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Want to include custom php file in page template only on specific parent & children

Discussion in 'Drupal' started by Ameria, Feb 11, 2011.

  1. #1
    Hi!

    I'm hoping someone with some Drupal and PHP experience might be able to help me figure out the code for this. I'm running Drupal 6.2 with the current Menu module and have created custom header PHP files that I want to include as part of the page.tpl.php file -- but only if the current node ID is one of a specific primary link or any of that link's children in the menu hierarchy.

    So essentially, I think I'm looking for something like this:

    <?php
    if ($node->nid == 2) //Only I want to also include all the links nested under that id in the menu structure
    include("sites/all/themes/mytheme/header2.php");
    else if ($node->nid == 3) //Plus all children
    include("sites/all/themes/mytheme/header3.php");
    else
    include("sites/all/themes/mytheme/header.php");
    ?>

    Any idea how I'd go about setting this up?

    Thanks for looking!
     
    Ameria, Feb 11, 2011 IP
  2. historiasdemaria

    historiasdemaria Member

    Messages:
    138
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #2
    Well, it is hard to figure out what you really want to do.. or rather why do you want to do it this way
    You could create menu entries, and then files like header2.tlp.php for the children?
     
    historiasdemaria, Feb 12, 2011 IP
  3. PainLess

    PainLess Peon

    Messages:
    91
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Insert that code in your theme's template.php file.
     
    PainLess, Feb 19, 2011 IP
  4. Tearabite

    Tearabite Prominent Member

    Messages:
    4,629
    Likes Received:
    429
    Best Answers:
    0
    Trophy Points:
    300
    #4
    Will the nodes in the Links or children be changing, or stay static? If they are always going to be the same and if i am understanding you correctly, you should be able to make a custom page.tpl.php file for each of those pages.
    Just make a copy of your page.tpl.php file, make your desired changes, then name it page-nodexyz.tpl.php (where nodexyz=the actual node) and drop it in your themes directory..
     
    Tearabite, Feb 19, 2011 IP