As a slight aside, the programmer in me is not liking the structure of this code now. Lots of nested IF's are never pretty, is there no SELECT CASE type structure I could use instead?
Either way, the code would be more efficient if the most commonly implemented item was the first logical step in the IF, with the least commmon condition last. Currently the tests go in this order:
- The first IF checks for static pages
- followed by category pages
- then the home page
- finally product pages.
I would have thought that testing should more correctly go in this order:
- Home page
- Category page
- Product page
- Static page
So how about something like this:
Code:
<title>{strip}
{*CAM Check for home page*}
{if $main eq "catalog" AND $current_category.categoryid eq ""}
{$lng.txt_site_title}
{else}
{*CAM Check for Category page *}
{if $current_category.categoryid and $current_category.meta_title and not $product.productid}
{$current_category.meta_title}
{else}
{*CAM Check for Static page*}
{if $page_data.metatitle}
{$page_data.metatitle}
{else}
{*CAM Must be product page*}
{capture name=title}
{if $config.SEO.page_title_format eq "A"}
{section name=position loop=$location}
{if not %position.first%} | {/if}
{$location[position].0|strip_tags|escape}
{/section}
{else}
{section name=position loop=$location step=-1}
{if not %position.first%} | {/if}
{$location[position].0|strip_tags|escape}
{/section}
{/if}
{/capture}
{if $config.SEO.page_title_limit <= 0}
{$smarty.capture.title}
{else}
{$smarty.capture.title|replace:" ":" "|truncate:$config.SEO.page_title_limit|replace:" ":" "}
{/if}
{/if}
{/if}
{/if}
{/strip}</title>
Ok that's not quite what I was hoping for as it checks for the static page before the product page.
I'm also not sure what the section that starts
{if $config.SEO.page_title_limit <= 0} does, and whether that should be outside of the Product Page IF block, as currently that doesn't get run for the home page, category pages or static pages.
Sorry, I'll stop my rambling now.