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.

How to show Title of the Entries in Browser Title Bar?

May 27, 2011 6:16pm

Subscribe [4]
  • #1 / May 27, 2011 6:16pm

    Ibn Saeed

    98 posts

    Hello

    How to automatically show Title of the Entries in Browser Title Bar?

    Here is my header contents:

    <!DOCTYPE html>
    
    <html >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Test Site</title>
        <link rel="stylesheet" href="{stylesheet=site/site_css}" type="text/css" media="screen" />
       
    </head>
  • #2 / May 28, 2011 2:36pm

    John St-Amand

    865 posts

    Several different approaches that I’m aware of:

    - you can use a separate channel entries tag pair to pull up the title (using the same setup and parameters as you do in the body)
    - there’s one or more add-ons on devot-ee.com that will temporarily cache a value from your entries pair in the site body and therein allow you to use it in the header or elsewhere in your template outside of the confines of the original entries tag pair, and then you wouldn’t have the inefficiency of duplicating the channel entries call.
    - i would suspect there’s a way to do it by PHP, that that’s not something I know how to do

    Hope that is useful. I’m sure others can chime in with other specific approaches.

  • #3 / May 28, 2011 4:00pm

    Kernon

    173 posts

    You asked about showing the title of “entries”—is the template just showing a single entry or multiple?  If the latter, how are you going to decide which of the several possible titles to use?

    Shown below is a Javascript approach that assumes you want to use the title of whatever is the first entry (this would obviously appear within the channel/weblog tag).

    {if count==1}
    ‹script type=“text/javascript”›
    document.title=’{title}’;
    ‹/script›
    {/if}

  • #4 / May 28, 2011 4:06pm

    Ibn Saeed

    98 posts

    What i want is that when a visitor view any article, the name of the Article should automatically appear in the Title Bar of the browser for SEO purposes.

    How is that acomplished ?

  • #5 / May 28, 2011 4:10pm

    Kernon

    173 posts

    If you don’t know how to implement John’s (or my) idea(s), you’ll need to post at least a snippet of the EE template code you are using to display an article.  But, again, whatever field contains the name could be substituted for “title” in the example code I provided.

  • #6 / May 31, 2011 9:30am

    Boyink!

    5011 posts

    Do you have your header HTML stored in an embedded template, or is it stored in the single-entry template?

  • #7 / May 31, 2011 9:32am

    Ibn Saeed

    98 posts

    Do you have your header HTML stored in an embedded template, or is it stored in the single-entry template?

    Hello

    I have my header in an embedded template.

  • #8 / May 31, 2011 9:36am

    Boyink!

    5011 posts

    Then pass the entry title from the single-entry template using an embed variable.

    The general approach is covered in this tutorial.

  • #9 / May 31, 2011 9:38am

    Ibn Saeed

    98 posts

    Then pass the entry title from the single-entry template using an embed variable.

    The general approach is covered in this tutorial.

    Thanks
    Ill go through your tutorial

    By the way, i have seen this mentioned alot “single-entry template” what does it refer to ?

  • #10 / May 31, 2011 9:40am

    Boyink!

    5011 posts

    A template that is designed to show a single entry….

  • #11 / May 31, 2011 9:42am

    Ibn Saeed

    98 posts

    A template that is designed to show a single entry….

    entry meaning a Template created under a Template group ?

  • #12 / May 31, 2011 11:30am

    Ibn Saeed

    98 posts

    Then pass the entry title from the single-entry template using an embed variable.

    The general approach is covered in this tutorial.

    I read through the tutorial but it only shows the way to manually set Page Title for each Page.

    What i need is for page to display the Title of the Article automatically in the Browser bar , how can i achieve that ?

    I tried adding {title} to the variable
    {embed="includes/document_header" my_page_title="{title}”}


    But it just showed {title}

  • #13 / May 31, 2011 11:38am

    Boyink!

    5011 posts

    Just fill the embed variable with the {title} tag from a channel entries loop.

  • #14 / May 31, 2011 11:42am

    Ibn Saeed

    98 posts

    Just fill the embed variable with the {title} tag from a channel entries loop.

    I did not understand

  • #15 / May 31, 2011 2:54pm

    Ibn Saeed

    98 posts

    Got it to work.

    But isnt running the channel tag twice on each page have an effect on the sites speed ?

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

ExpressionEngine News!

#eecms, #events, #releases