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.

Embed variables to display dynamic page titles

December 11, 2008 6:33am

Subscribe [2]
  • #1 / Dec 11, 2008 6:33am

    berkeley

    32 posts

    Is it ok to put EE tags in the embed variable like this?

    {embed="includes/header" title="{exp:weblog:category_heading weblog="{my_weblog}"}
    {category_name}{/exp:weblog:category_heading}"}

    I’m using this with a conditional in the embedded template to generate dynamic page titles (the <title> part of the HTML <head>). So, if the user is on the homepage they get the homepage title, if they’re on the article page they get the article title in the page title, and if they’re on a category page they get the category name in the page title. This is the conditional:

    {exp:if_homepage}
    {if is_homepage}
    <title>This is the home page title</title>
    {if:elseif segment_2 == ''}
    <title>{embed:title}</title>
    {if:elseif segment_3 == 'category'}
    <title>{embed:title}</title>
    {if:else}
    <title>{exp:weblog:entries rdf="off" limit="1"}{blog_title} : {title}{/exp:weblog:entries}</title>
    {/if}
    {/exp:if_homepage}

    It all seems to work, but I want to check that having EE tags in the embed variable is OK to do?

  • #2 / Dec 11, 2008 11:49am

    Boyink!

    5011 posts

    Sure…it’s my standard approach.

  • #3 / Dec 11, 2008 11:54am

    berkeley

    32 posts

    Thanks Boyink - glad to hear I’m on the right track.

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

ExpressionEngine News!

#eecms, #events, #releases