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,

adpboss 06-29-2004 07:59 AM

Your page title is generated dynamically by X-Cart based up on location.

This changes the default code and optimises the title to be more search engine friendly.

Search Engines take several factors into account when spidering a page, and the title text is an important factor to how the page gets placed in a Search Engine's index.

Jon 06-29-2004 09:12 AM

In addition, with the original x-cart code often page titles appear like this:

<title>Site Title Here -
Product Name
</title>

This code changes the text to appear on 1 line:

<title>Site Title Here - Product Name</title>

Which is more search engine spider friendly.

Risky 06-30-2004 06:04 AM

Jon / adpboss .. thanks greatly for elaborating. I really had trouble understanding this one. On the surface, this is just such a minor change but I'll take your word for it about its potential importance and adopt the change.

I presume the x-cart people would know the importance of such formating also and can't help but wonder why they wouldn't adopt this into the base product. Its not as if the whole x-cart community wouldn't benefit, nor that there was likely to be disagreement as to the mods worth. I thought there was a thread here for enhancement suggestions to the base .. shouldn't this be offered up there.

Thanks again,

adpboss 06-30-2004 06:19 AM

It could go in Wishlists, but X-Cart has bigger fish to fry than this.

Their code works just fine. This is a modification or enhancement. It won't make or break your store, none of these modifications will. But if you understand what these mods do, and how they do it, then you can add some nifty features and useful stuff to your site.


All times are GMT -8. The time now is 12:44 AM.

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