4

OK, so i've had a great deal of help on here on the rebuild of my site, and I'm onto the last part which is to make sure my pages meta, titles etc are working well.

I have switched (pun) a lot of my templates to using Switchee, and its been really great.

So far I have a few templates that have a global head embed, that inserts basically just the <head>. Then the main structure of my page with Switchee controlling what content is shown within the main content area.

I have normally used SEO lite, and I like it, but I'm starting to think what the best way to use it with multiple content within a single template is?

Do you think it is best to run a conditional on the embed to determine what content is passed through with the embed to SEO Lite. Or to maybe include a different global head embed with each Switchee case?

Just trying to get my head around the best way to do it, without needlessly repeating things!

Any thoughts appreciated, or if anyones utilised the two together, I'd be interested to hear what they think.

UPDATE

OK, thanks for that tip. I've actually tried it just now, and I can see the benefits. However I am a bit unsure as to how to deal with a certain scenario.

Lets say I have my 'news' index page. This consists of an instance of Switchee, that determines if it is the

  • default {latest articles) index page (domain.com/news)
  • category page. {domain.com/news/category)

Now, my template is something along the lines of

{embed="includes/_head"}

{lv_page title}

<div class="container">

 <div class="main-content">

  {exp:switchee variable="{segment_2}" parse="inward"}

  {case value="" default="yes"}

  {exp:channel:entries channel="news" status="open" paginate="bottom"}

    {lv_news_article_details}

  {/exp:channel:entries}

  {/case}

  {case value="category"}

  {exp:channel:entries channel="news" category="{segment_3_category_id}" status="open" paginate="bottom"}

    {lv_news_article_details}

  {/exp:channel:entries}

  {/case}

  </div>

{lv_sidebar_news}

</div>

{lv_footer}

That's a very simplified version. Now my template shares the same global head embed, but I will want the Title to be "Latest News" for the first case, and "Category News" for the second case. What would be the best way of passing that information to the embed, more conditionals?

4

We use this code in our header embed; allows us to do something like {embed="site/_header" meta_title="Example Title"}; alternatively we can specify an entry ID, and SEO Lite will figure out the correct info, or, we can just let it rely on the last segment, which works 95% of the time.

It's worth noting that we're also using Mark Croxton's IfElse add-on here to keep things nice and speedy.

{exp:ifelse parse="inward"}
    {if "{embed:meta_title}"}
        {exp:seo_lite title_override="{embed:meta_title}"  default_keywords="{embed:meta_keywords}" default_description="{embed:meta_description}"}
    {if:elseif "{embed:entry_id}"}
        {exp:seo_lite entry_id="{embed:entry_id}"}
    {if:else}
        {exp:seo_lite use_last_segment="yes"}
    {/if}   
{/exp:ifelse}
| improve this answer | |
  • Thanks, updated my original post to expand the question a bit further. – shorn Feb 8 '13 at 22:45
  • I'm gonna go ahead and mark as an answer. I used this idea to get mine working well. All works now, with the help of some conditionals on the switchee pages, and it all works well! Cheers – shorn Feb 11 '13 at 0:24
  • Nick, been successfully using SEO Lite for a while, just realized the other day that when I add override titles/keywords within an entry that they aren't displaying and the defaults keep displaying. Is the {embed:xx} required to override? I always thought it was more automatic with the standard tag {exp:seo_lite use_last_segment="yes"} – Mike Lohrman Jul 31 '13 at 12:18
  • Mike, apologies for the latency, haven't checked in here in a while. SEO Lite will automatically display the correct values per the entry using entry_id or last_segment; if you want to do anything custom, you need to define the value of the title, keywords, and description explicitly via your embeds using {embed:xx} tags, if that makes sense. – Nick Benson Sep 13 '13 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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