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

[Docs] Setting the Title Tags

Discussion in 'Archived Docs' started by Nick, Aug 1, 2009.

  1. Nick

    Nick Well-Known Member

    Please read About Title Tags in the Themes documentation before learning how to set them from a plugin.

    Use the Hotaru object

    The best place to set your title tags is from the hotaru_header hook.

    Use isPage or keyExists to determine the page

    If your query string contains a page argument, you can use that to set your title, e.g.

    if ($this->hotaru->isPage('myplugin')) {
    $this->hotaru->title "My Title";
    Otherwise, the keyExists function in Inspekt enables you to check for url parameters that might determine what page you're on. Here are two real-life examples:

    if ($this->cage->get->keyExists('category')) {

    if ($this->cage->get->keyExists('tag')) {
    The categories and tags plugins use those to determine if we're looking at a page of posts filtered to a specific category or tag.

    Make your title readable

    Once you know you're on the right page, you can simply set the title as follows:

    $hotaru->title "My Title";
    However, you'll most likely want to convert a value into a title, and to do that, Hotaru has some built-in formatting functions:

    will give you My title.

    If you want to make all the words start with an uppercase letter, use:

    which results in My Title.

    So you might end up with something like:

    $this->hotaru->title $hotaru->pageToTitleCaps('my_title'));
    Last edited: Jan 6, 2010

Share This Page