0

I'm trying to add a different title to inside pages of a specific channel. I have the logic down (I think), but am not quite sure how to determine if I'm getting served a single entry page:

<title>
{if embed:channel =='news'}
    {if [test for single page]}
        {embed:title}
    {if:else}
        News Index Page Title
    {/if}
{if:else}
    {embed:title}    
{/if}
</title>

Is this possible?

1
  • Do just want to display the appropriate title for an article? Say: "No new taxes?" says Gov. Walker" - My Site, in the <title> tag. Or do you want to change the title of the article? Apr 12, 2013 at 20:13

2 Answers 2

2

Just always pass title as an embed parameter in your template. So in news/index, you'd pass title="News", and in news/entry you'd pass title="{title}", or perhaps title="{title} - News".

Then in your embed:

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

In other words - perform the logic in your template, not in your embed.

1
  • Thank you. Your last line was what I needed and I found the template to edit... no logic required! EE is like a whole new monster to me and I'm still trying to wrap my head around it. Thanks again!
    – Yazmin
    Apr 13, 2013 at 2:02
0

If you're just looking for how to handle title and sections in the <title> tag, we use variations of this:

{exp:channel:entries channel="not forms" limit="1" show_future_entries="no" disable="categories|member_data|custom_fields|pagination|trackbacks"}

    <title>
        {if segment_2=="articles" AND title != ''}MySite - {title}
        {if:elseif segment_2 =="" AND segment_2 !="articles" AND segment_1 != ''}MySite - {exp:phpstringfun function="ucwords"}{exp:low_replace find="_" replace="SPACE"}{segment_1}{/exp:low_replace}{/exp:phpstringfun}
        {if:elseif segment_2 !="" AND segment_1 != ''}MySite - {exp:phpstringfun function="ucwords"}{exp:low_replace find="_" replace="SPACE"}{segment_1}{/exp:low_replace}{/exp:phpstringfun} :: {exp:phpstringfun function="ucwords"}{exp:low_replace find="_" replace="SPACE"}{segment_2}{/exp:low_replace}{/exp:phpstringfun}
        {if:else}
            MySite - {tagline}
        {/if}
    </title>

{/exp:channel:entries}

We set-up most sites, so that there is an article page that triggers the single post view. We may call it something other than article, but that's the primary trigger. The secondary triggers are for section pages, like News or About.

I've included our strip and format plugin use. You can use whatever you want, but we use PHPStringFun and Low Replace. This code is just in the header file for the site, and handles everything regarding <title> with little problem. It's our starter. We occasionally add a few lines with other checks.

Also we deliberately use the not in channel specification, so it processes everything, except a section never used on the front-end. We choose forms since we store all forms in a single area, then embed them where needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.