• Hi,
    i’m trying to use WP as a CMS ( https://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!

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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… ??

    Thread Starter Christoph

    (@mandolito)

    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…

    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.

    Thread Starter Christoph

    (@mandolito)

    Ahh thank you Sumeetjain! That’s what I was looking for…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using WP as CMS’ is closed to new replies.