Results 1 to 1 of 1

Thread: Setting the Title Tags

  1. #1
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,860
    Blog Entries
    88
    Thanks
    484
    Thanked 809 Times in 528 Posts

    Default Setting the Title Tags

    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.

    PHP Code:
    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:

    PHP Code:
    if ($this->cage->get->keyExists('category')) { 
    and

    PHP Code:
    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:

    PHP Code:
    $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:

    PHP Code:
    $this->hotaru->pageToTitle('my_title'); 
    will give you My title.

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

    PHP Code:
    $this->hotaru->pageToTitleCaps('my_title'); 
    which results in My Title.

    So you might end up with something like:

    PHP Code:
    $this->hotaru->title $hotaru->pageToTitleCaps('my_title')); 
    Last edited by Nick; 01-06-2010 at 02:37 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Docs] About the Title Tags
    By Nick in forum Design and Layout
    Replies: 0
    Last Post: 08-01-2009, 12:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •