WordPress.org

Ready to get started?Download WordPress

Forums

Using WP as CMS (5 posts)

  1. Christoph
    Member
    Posted 8 years ago #

    Hi,
    i'm trying to use WP as a CMS ( http://senior.brotkasting.de/ ). I have a first- and a second-level navigation and want the first-level navigation to be highlighted even if I choose an entry from the second-level navigation. Is there a function to query the template name? Like:
    If template_name == "bla" {echo...}
    I hope someone gets my point :-)
    Thank You!

  2. Ment0r
    Member
    Posted 8 years ago #

    you need to catch the call for the "second level" before building the "first-level" and then compare.

    hmm.. you could start a browser session to make that information available to all pages..

    header:
    session_start();

    secondlevel template:
    $_SESSION['section'] = "wegweiser";

    header (part 2)
    if($_SESSION['section'] == "wegweiser") {
    echo "<a href=# class='highlight'>Wegweiser</a>";
    } else {
    echo "<a href=# class='normal'>Wegweiser</a>";
    }

    untested..

    Ps: zu risiken und nebenwirkungen fragen sie... ;)

  3. Christoph
    Member
    Posted 8 years ago #

    Hmm, thank you for your reply... but I think there must be a much easier way. Because for example all pages that belong to "wegweiser" have the page-template "wegweiser.php". So it would be enough to say "if the the page uses the template 'wegweiser' then highlight the navigation item "wegweiser". But I don't know how to request the template name...

  4. sumeetjain
    Member
    Posted 8 years ago #

    If your pages each have unique templates, just stick a variable in the template:

    <?php $this_page="wegweiser"; ?>

    Then have your navigation buttons render highlights based on the value of the $this_page variable.

  5. Christoph
    Member
    Posted 8 years ago #

    Ahh thank you Sumeetjain! That's what I was looking for...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.