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.

dynamically grab title from segment for meta

September 15, 2010 8:19pm

Subscribe [2]
  • #1 / Sep 15, 2010 8:19pm

    This question is for EE v1.6.8.

    I have a template that displays an entry based on segment_3 in the url.

    {exp:weblog:entries weblog="dictionary" limit="1" disable="categories|member_data|trackbacks"}
    {title}
    {/exp:weblog:entries}

    I also use an embed with a variable to generate meta data. So I have the following code:

    {embed="global/header" sm_page_title="Dictionary Term: "}

    The sm_page_title variable is used to generate the meta tag: <title>Dictionary Term: </title>

    I would also like to send the title of the currently displayed entry (in this case a dictionary term) to the global/header. I figured the best way is to get the title based on what is the URL, i.e.

    <a href="http://www.domain.com/resources/dictionary/term">http://www.domain.com/resources/dictionary/term</a>

    So I want to get the title for the “term” and send it with the sm_page_title to global/header to display in the meta tag.

    I feel like I should know how to do this, but I’m blanking on the solution. Any help would be appreciated.

  • #2 / Sep 17, 2010 1:17pm

    ajlny

    42 posts

    Not sure if I’m understanding you completely, but can you simply pass the title to the embed?

    {exp:weblog:entries weblog="dictionary" limit="1" disable="categories|member_data|trackbacks"}
    {embed="global/header" sm_page_title="Dictionary Term: " title="{title}"}  
    {title}
    {/exp:weblog:entries}
  • #3 / Sep 17, 2010 2:59pm

    I was thinking incorrectly about the parsing order of a template, and for some reason thought that wouldn’t work. Of course, it works. Thanks!

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

ExpressionEngine News!

#eecms, #events, #releases