ThemeShaper Forums » Thematic

Multiple headers with subpages

(5 posts)
  • Started 5 years ago by alst
  • Latest reply from alst
  • This topic is resolved
  1. alst
    Member

    Hi,

    Using wordpress as a CMS and after spending far too much time implementing the "pretty" lava lamp functionality in the top nav menu I have hit a snag that is bothering me.

    Essentially, if a user clicks on a page that is a sub-page of a top level parent page, then page.php needs to call a certain header. If the parent page is different then a different header is called.
    This is to force the default location of the menu highlighting to stay on the parent page rather than defaulting back.

    There are only two top level pages that I want this to happen on, so using the code from the codex page I tried this,

    <?php

    if (is_page() || $post->post_parent=="65") {
    $subpagefix="/header-resources.php";
    } elseif (is_page() || $post->post_parent=="221") {
    $subpagefix="/header-quickref.php";
    } else {
    $subpagefix="/header.php" ; // Fall-through
    }

    ?>
    <?php include (TEMPLATEPATH . $subpagefix ); ?>

    Admittedly, I am obsessing over a detail, but like I said, it took me so long to get the thing to work at the start, and it has become and important indicator of location for the user.

    Hope someone can help.

    Posted 5 years ago #
  2. I'm not sure I understand the problem. But I've been thinking about using Lava lamp in a theme. Do you have a test site up?

    Posted 5 years ago #
  3. alst
    Member

    Unfortunately not Ian, have been building it on a localhost setup and it will be in house only. I'llemail you the theme folders and plugin folders I've been using though if you want to have a look.

    The problem with lavalamp is that if it doesn't find the class "current"(changed by me to current_page_item) for the page it defaults either back to the left hand menu option or the option designated in the actual script file in the page header(using the linum call). This works fine by having individual header files for each page but when you go to a subpage I need to force the page.php file to call the header-file for the top level page.

    The function above should do that, but I wonder if I need to take out the (is_page) part which I'm going to try tonight.

    Cheers,

    Alistair

    Posted 5 years ago #
  4. alst
    Member

    Ah, the joys of learning php by cut and paste,

    this seems to work. getting rid of the "" around the page number was the key.

    <?php
    
    if      (is_page() && $post->post_parent==65) {
            $subpagefix="/header-resources.php";
    } elseif (is_page() && $post->post_parent==221) {
            $subpagefix="/header-quickref.php";
    }
    else  $subpagefix="/header.php"
    
    ?>
    
    <?php  include (TEMPLATEPATH . $subpagefix);  ?>
    Posted 5 years ago #
  5. alst
    Member

    The definitive fix which ensures dyanmically created subpages of subpages call the right header to make sure lavalamp defaults to the correct page.
    This is for Wordpress as a CMS where a function (such as dd_list_subpages) dynamically populates a page with it's subpages.

    <?php
    //this code uses fold_page_list plugin to generate array of ancestor pages
    and sets grandparent as top level page
    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $grandParent = $ancestorIDs[1];
    
    ?>
    <?php
    //this code keeps lavalamp on the correct parent page when viewing
    a subpage, add elseif for other top level pages as appropriate
    if      ($grandParent==65) {
            $subpagefix="/header-resources.php";
    } elseif ($grandParent==221) {
            $subpagefix="/header-quickref.php";
    }
    else  $subpagefix="/header.php"
    
    ?>
    
    <?php  include (TEMPLATEPATH . $subpagefix);  ?>
    Posted 5 years ago #

RSS feed for this topic

Reply

You must log in to post.