1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Docs] Getting the Page Name

Discussion in 'Design and Layout' started by Nick, Nov 8, 2009.

  1. Nick

    Nick Well-Known Member

    In most cases, Hotaru uses specific templates for each page, so you can edit them directly without having to use conditions to see which page you're looking at. However, some pages are multi-purpose so you'll need to test for the page name in order to customize it.

    One of the first things Hotaru does is check to see if there's a "page" parameter in the url, or submitted from a form. If so, this value is assigned to...

    If you'd like get the page name yourself, you can get it directly using:

    $page $h->cage->get->testPage('page'); // from the url
    $page $h->cage->post->testPage('page'); // from a form
    Or, you can just do this:

    $page $h->getPageName(); // this is what Hotaru did to get $h->pageName;
    In most cases, you'll simply want to check the current page name, which you can do like this:

    if ($h->pageName == 'index') { echo "This is the index page."; }
    Sometimes, you need more information than just the page name, so Hotaru provides a few extra properties which are filled by various plugins. They are:

    $h->pageName // e.g. index, latest, upcoming, all, profile, submit2, comments
    $h->subPage // e.g. filtered to category, tags, user
    $h->pageType // e.g. list, post, user, submit
    $h->pageTitle // e.g. Top Stories, User Profile, Latest Comments
    $h->pageTemplate // e.g. sb_list, tag_cloud, users_profile
    Here's an example of values if you're looking at the latest posts in a "News" category:
    echo $h->pageName// latest
    echo $h->subPage// category
    echo $h->pageType// list
    echo $h->pageTitle// News
    echo $h->pageTemplate// sb_list
    If and how these properties are used is determined by individual plugins.
    Last edited: Jan 7, 2010

Share This Page