ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Customising HTML Title Tags to display Category Names

September 24, 2010 8:24am

Subscribe [2]
  • #1 / Sep 24, 2010 8:24am

    GeorgiaJ

    10 posts

    Hi, I would like to be able to display category names in my HTML title tags.

    My site is: http://www.getdialing.com

    I have a template index page which is used for my main categories: Landline, Mobile, Voip, Mobile Voip, Phone Cards, Free Calls. This is one category group.

    This is the code I’m using:

    <title>
    Make Cheap Phone Calls: {exp:weblog:entries weblog="{my_weblog}" category_group="1" limit="1"} 
    {categories}{category_name}, {/categories}{/exp:weblog:entries}
    </title>

    What I would like to do is to display a title tag containing the category name “Landline” when this page is requested, something like this: “Make Cheap Landline Phone Calls” and the same for other categories eg. “Make Cheap Mobile Phone Calls”.

    Is this possible, and if so, how can I do it?

    At the moment I have the same HTML title tag for several pages, which I’d like to avoid. However, even though all these pages are generated from the same template, the title tags on two of the categories show differently, which I don’t understand. This happens whether I use category_group=“1” or not. In some cases, category names from other category groups are showing too.

    As I’m sure you can tell from my question, I’m not a programmer so I would really appreciate if you could keep any explanation simple 😊

    thanks

  • #2 / Sep 24, 2010 10:52am

    Ingmar

    29245 posts

    Yes, doesn’t your code work as intended?

    <title>
    {exp:weblog:entries weblog="{my_weblog}" category_group="1" limit="1"} 
       {categories}
          Make Cheap {category_name} Phone Calls
       {/categories}
    {/exp:weblog:entries}
    </title>

    Something like that, anyway. Moving to the CodeShare Corner.

  • #3 / Sep 24, 2010 11:15am

    GeorgiaJ

    10 posts

    Hi, my code is working, but pulls in all category names within the category group.

    Make Cheap Phone Calls:

    {exp:weblog:entries weblog="{my_weblog}" limit="1"} {categories}{category_name}, {/categories}{/exp:weblog:entries}

    Which you can see on this page: http://www.getdialing.com/index.php/services/browse/landline/

    When I replaced it with your code, the page generated an error message:

    The following tag cannot be processed:

    {exp:weblog:entries weblog=“listing” category_group=“1” limit=“1”}

    Please check that the ‘weblog’ module is installed and that ‘entries weblog=“listing” category_group=“1” limit=“1”’ is an available method of the module

    What I want to do is just to have the Landline category name showing in the title tag when the Landline page is generated, and the Mobile category name showing in the title tag when the Mobile page is generated etc.

  • #4 / Sep 28, 2010 5:48am

    GeorgiaJ

    10 posts

    Any chance of a reply to this question please?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases