X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Optimizing Page Title Text (https://forum.x-cart.com/showthread.php?t=3380)

walteis 06-29-2003 11:22 AM

Optimizing Page Title Text
 
From what I've read, extra spaces or non-displaying characters (like CR or LF) make search engines unhappy, so to speak. I've noticed that x-cart seems to put some of those in there however.

The following smarty 2.5.x code will fix that problem. Add to customer/home.tpl
Code:

{assign var="loc" value=" "}
{if $main eq "catalog"}
    {if $location eq ""}
      {assign var="loc" value=$lng.txt_subtitle_home|strip}
        {else}
          {section name=index loop=$location}
                  {assign var="loc" value=$loc|cat:" - "}
                {assign var="loc" value=$loc|cat:$location[index].0|strip}
          {/section}
        {/if}
{elseif $main eq "product"}
        {assign var="loc" value=" - "|cat:$product.product|strip|default:""}
{elseif $main eq "help"}
{assign var="loc" value=$lng.txt_subtitle_help}
{elseif $main eq "cart"}
{assign var="loc" value=$lng.txt_subtitle_cart}
{elseif $main eq "checkout"}
{assign var="loc" value=$lng.txt_subtitle_checkout}
{elseif $main eq "order_message"}
{assign var="loc" value=$lng.txt_subtitle_thankyou}
{/if}
<title>{$lng.txt_site_title}{$loc}</title>


Walt

phpguy 04-05-2004 01:46 AM

Hey, thanks for posting that code Walt. Am I the only one in four months to make use of it? ;)

BTW, if anyone else has tried this, do you also get alot of spaces generated in the output source code between the </head> and <title> tags? I do, is this going to be of a problem to spiders?

GM 05-29-2004 10:10 PM

Hmmmm... I wonder if this works? Looks good, little bit scared to try it, but always like to improve. :lol: Thanks walteis nice post.

TelaFirma 05-30-2004 03:54 AM

Or you could just take your existing code for the title tag and add the {strip} tag. This tag strips out all the extra line feeds in HTML.

Example from 3.5.x:

Code:

{strip}
<title>{$lng.txt_site_title}
{if $main eq "catalog"}
        {if $location eq ""}  {$lng.txt_subtitle_home}
        {else}
        {strip}
        {section name=position loop=$location start=0 }
        {if %position.last% eq "true"} - {$location[position].0|escape}{/if}
        {/section}
        {/strip}
        {/if}
{elseif $main eq "product"}
        {if $product.product ne ''} - {$product.product}{/if}
{elseif $main eq "help"}
{$lng.txt_subtitle_help}
{elseif $main eq "cart"}
{$lng.txt_subtitle_cart}
{elseif $main eq "checkout"}
{$lng.txt_subtitle_checkout}
{elseif $main eq "order_message"}
{$lng.txt_subtitle_thankyou}
{elseif $main eq "wishlist"}
{$lng.txt_subtitle_wishlist}
{elseif $main eq "giftcert"}
{$lng.txt_subtitle_giftcerts}
{/if}
</title>
{/strip}


xcell67 05-31-2004 02:44 PM

telafirma,
your code causes {/strip} to be displayed on the home page, I tried moving it before </title> but then it causes {/strip} to be added onto the title of the page ie X-cart Books {/strip}

is there an easier way or did i read the code wrong?

TelaFirma 06-01-2004 03:09 AM

oops... my fault. I failed to take into account the {strip} tags that were already in the code.

Try this:
Code:

{strip}
<title>{$lng.txt_site_title}
{if $main eq "catalog"}
  {if $location eq ""}  {$lng.txt_subtitle_home}
  {else}
  {section name=position loop=$location start=0 }
  {if %position.last% eq "true"} - {$location[position].0|escape}{/if}
  {/section}
  {/if}
{elseif $main eq "product"}
  {if $product.product ne ''} - {$product.product}{/if}
{elseif $main eq "help"}
{$lng.txt_subtitle_help}
{elseif $main eq "cart"}
{$lng.txt_subtitle_cart}
{elseif $main eq "checkout"}
{$lng.txt_subtitle_checkout}
{elseif $main eq "order_message"}
{$lng.txt_subtitle_thankyou}
{elseif $main eq "wishlist"}
{$lng.txt_subtitle_wishlist}
{elseif $main eq "giftcert"}
{$lng.txt_subtitle_giftcerts}
{/if}
</title>
{/strip}


xcell67 06-01-2004 02:17 PM

eh xa lent, thanks telafirma, worked beautifully

matt.currie 06-03-2004 06:45 PM

TelaFirma: Thanks for taking the time to post! worked excellent. It was high on my list of 'mods' that shockingly are not included in the X-Cart package.

Matt
Curtek Systems - http://www.curtek.com

Jon 06-28-2004 09:05 PM

Very handy, thanks for sharing.

Risky 06-29-2004 07:48 AM

I'm sorry to ask, but for the very lay shop owners amongst us, can you just briefly explain in plain language what this bit of code achieves.

It's got pretty good reviews, so I'm sure it's a worthy mod to adopt, but it would greatly help if I could understand exactly what effect it has on the store's appearance or workings.

Thanks in advance,


All times are GMT -8. The time now is 04:16 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.