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.

Page Titles

July 20, 2011 9:38am

Subscribe [4]
  • #1 / Jul 20, 2011 9:38am

    asidua

    14 posts

    Hi Everyone

    We are running EE 1.6.8.  We have a static page title that appears on each page.  I wanted to ask if anyone knew how to change this?

    I also seen somewhere that in EE 2.0 there is a plug-in that allows individual page titles to be set on each page.  Is there something similar for EE 1.6?  If so it would remove the need to change the static title.

    I will prob upgrade to EE 2.0 but, would need to do this in the quiet season as would need to test the links, templates etc before upgrading

    thanks for your input

  • #2 / Jul 20, 2011 10:21am

    Boyink!

    5011 posts

    You don’t need either an add-on or an upgrade to get dynamic page titles - but the way to get them implemented on your site is going to depend on how the existing site is implemented.

    Can you post the template code of an existing template that generates a page on the site?

  • #3 / Jul 20, 2011 11:03am

    asidua

    14 posts

    Yea see below….

    ##########################################################################################

    {embed="includes/_header"}

    {exp:weblog:entries weblog="{segment_1}”}
    {embed="includes/_sidebarCareers"}

    <div class=“grid_9”>
      <div class=“main_header clearfix”>
          <!—Breadcrumb Trail—>
          <div id=“bread”>
            <ol>
              <li class=“first”>Home</li>
              <li>> Careers</li>
              {exp:pages_crumbs segment="2"}<li>> {pc_title}</li>{/exp:pages_crumbs}
              {exp:pages_crumbs segment="3"}<li>> {pc_title}</li>{/exp:pages_crumbs}
              {exp:pages_crumbs segment="4"}<li>> {pc_title}</li>{/exp:pages_crumbs}
              {exp:pages_crumbs segment="5"}<li>> {pc_title}</li>{/exp:pages_crumbs}
              <li>> {title}</li>
            </ol>
          </div>
      </div>

      <h3 class=“styleme”>{title}</h3>
      {exp:replace find='<hr width="100%" size="2" />'; replace='<div class="hr"><hr /></div>'; }{body}{/exp:replace}{/exp:weblog:entries}
    </div>

    {embed="includes/_footer"}

    ##########################################################################################

  • #4 / Jul 20, 2011 11:14am

    Boyink!

    5011 posts

    I’d give this a shot with using embed variables for embedded templates.  This approach feeds the entry title into an embed variable that passes it through to the _header template where I assume the html title tag resides.  Note that the opening weblog:entries tag position has changed so that the title variable is available to the embed tag:

    {exp:weblog:entries weblog=”{segment_1}”}
    {embed=“includes/_header” my_page_title="{title}"}
    {embed=“includes/_sidebarCareers”}
    
    <div class=“grid_9”>
      <div class=“main_header clearfix”>
          <!—Breadcrumb Trail—>
          <div id=“bread”>
            <ol>
              <li class=“first”>Home</li>
              <li><span>></span> Careers</li>
              {exp:pages_crumbs segment=“2”}<li><span>> </span>{pc_title}</li>{/exp:pages_crumbs}
              {exp:pages_crumbs segment=“3”}<li><span>> </span>{pc_title}</li>{/exp:pages_crumbs}
              {exp:pages_crumbs segment=“4”}<li><span>> </span>{pc_title}</li>{/exp:pages_crumbs}
              {exp:pages_crumbs segment=“5”}<li><span>> </span>{pc_title}</li>{/exp:pages_crumbs}
              <li><span>> </span>{title}</li>
            </ol>
          </div>
      </div>
    
      <h3 class=“styleme”>{title}</h3>
      {exp:replace find=’<hr width=“100%” size=“2” >’; replace=’<div class=“hr”><hr ></div>’; }{body}{/exp:replace}{/exp:weblog:entries}
    </div>
    
    {embed=“includes/_footer”}

    And then in includes/_header:

    <title>{embed:my_page_title}</title>

    or

    <title>{site_name} : {embed:my_page_title}</title>

    Etc as needed.

  • #5 / Jul 20, 2011 11:16am

    asidua

    14 posts

    ok thanks I will give it a try.

  • #6 / Jul 20, 2011 11:26am

    asidua

    14 posts

    ok

    I added the code in and something happended on each attempt.

    When I added in ‘<title>{embed:my_page_title}</title>’ to the _header file, it removed all page titles.

    When I added in ‘<title>{site_name} : {embed:my_page_title}</title>’ it added in the site name followed by ‘:’ but there was no reference to the page itself

  • #7 / Jul 20, 2011 12:37pm

    Boyink!

    5011 posts

    Sounds like the embed variable isn’t being populated. If you copied code from here in the forums make sure quotes area all straight and not “smart” etc.

  • #8 / Jul 20, 2011 1:35pm

    asidua

    14 posts

    I also noticed that the /header template file has this included in the head

    <title>{company_name} - {meta_title}<?php echo $title;?></title>

    I tired removing that line and inserting either of the two lines suggested above.  But it still only brings back the site name followed by “:”

    I then tried to change the “meta_title” to “page_title”, then “title” (encase its not page_title) and what it did was display the site name followed by the “{page_title}” or “{title}”

  • #9 / Jul 20, 2011 1:40pm

    Boyink!

    5011 posts

    Do you have the following code in place:

    {embed=“includes/_header” my_page_title="{title}"}

    Embed variables have two parts - a pitcher and a catcher.  The value has to be pitched from the calling template and caught by the receiving template.

    If the receiving template isn’t catching anything then it’s usually either:

    - the value of the variable isn’t being pitched correctly
    - the embed variable doesn’t match between the pitching and catching templates (make sure both are using “my_page_title”).

    If all of that looks right then try hardcoding a value into my_page_title:

    {embed=“includes/_header” my_page_title="Test Title"}

    And see if the catcher template gets & displays that.

  • #10 / Aug 02, 2011 4:34pm

    jeffmace

    120 posts

    Thanks for these Title tip.  It is exactly what I was looking for!

  • #11 / Sep 29, 2011 2:28pm

    Hamish Brown

    12 posts

    Hi - Also looking to send blog title to <title> of page. Have seen you’ve pointed several people in right direction on this. Have been through the steps outlined above. EE version 2.2.2

    Here’s what i have in my single entry template. (The html tag is inside global variable ‘header1’)

    {preload_replace:blog_title="Comments"}
    {preload_replace:my_template_group="site"}
    
    {exp:channel:entries limit="1"}
    
    {header1}
    {embed="{my_template_group}/header-title"}
    {header2}
    
    <h2 class="title">{title}</h2>
    {embed="{my_template_group}/header-title" my_page_title="{title}"}
    {body}
    
    {/exp:channel:entries}

    The contents of the included ‘header-title’ template is:

    <title>{sitetitle}: {embed:my_page_title}</title>

    Result in title is just: “Sitetitle text: “

    However the result of the code

    {embed="{my_template_group}/header-title" my_page_title="{title}"}

    outputs the <title> text i want, including the title tags, but in the wrong place. Like pitcher and catcher are wrong way round.

    Also tried

    my_page_title="{Test Title}"}

    But not displayed in <title>

     

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

ExpressionEngine News!

#eecms, #events, #releases