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)
-   -   Display Only Current Page in Page Title (https://forum.x-cart.com/showthread.php?t=19842)

TJ Stephens 02-09-2006 12:57 AM

Display Only Current Page in Page Title
 
I am not sure if this is worthy to be in the custom mods section but I will post anyway since I could not find a clean way to do this on the forum.

Xcart currently gives you only two options for page title format: (1) "Shop Name :: Category Name :: Product Name," or (2) "Product Name :: Category Name :: Shop Name." This mod adds a third option called "Current Page Only" which displays only the current page you are viewing. Some people claim this helps with SEO.

For example, if you are on the home page, it will display your site name as the page title, if you are viewing a category, it will display the category and nothing else, and if you are viewing a product then it will display the product name and nothing else, etc...

First, edit skin1/admin/configuration.tpl and find the following code:

Code:

{elseif $configuration[cat_num].name eq "page_title_format"}
<SELECT name="{$configuration[cat_num].name}">
<OPTION value="A" {if $configuration[cat_num].value eq "A"}selected{/if}>Shop name :: Category name :: Product name</OPTION>
<OPTION value="D" {if $configuration[cat_num].value eq "D"}selected{/if}>Product name :: Category name :: Shop name</OPTION>
</SELECT>


Then add the following line after the last option:

Code:

<OPTION value="G" {if $configuration[cat_num].value eq "G"}selected{/if}>Current Page Only</OPTION>

Then edit skin1/customer/home.tpl and replace everything between the <TITLE> tags with the following:

Code:

<TITLE>
{if $config.SEO.page_title_format eq "A"}
{section name=position loop=$location}
{$location[position].0|escape}
{if not %position.last%} :: {/if}
{/section}
{elseif $config.SEO.page_title_format eq "D"}
{section name=position loop=$location step=-1}
{$location[position].0|escape}
{if not %position.last%} :: {/if}
{/section}
{elseif $config.SEO.page_title_format eq "G"}
{section name=position loop=$location}
{if %position.last%}{$location[position].0|escape}{/if}
{/section}
{/if}
</TITLE>


Finally, make sure that you have selected "Current Page Only" in the admin area under General Settings --> SEO Options --> Page Title Format. This was done in 4.0.14. It may be different in other versions but you get the idea. Hope that helps.

T.J.

PhilJ 03-02-2006 05:02 AM

Just thought I'd say thanks for this mod... makes absolute sense for SEO.

cotc2001 05-26-2006 11:54 PM

Works great, one question though
Because say for example the help pages are essentially the same page but with just different language variables controlled by the appending variable in the url string, how would I stop it from displaying the same title tag all the way through.

In my home.tpl i used to have

Code:

{elseif $main eq "product"}{if $product.product ne ''}{$product.product} | {if $current_category.page_title eq ""}:{$current_category.category_name|regex_replace:"/.*\//":""}:{$config.Meta.site_title}{else}{$current_category.page_title}{/if}{/if}
{elseif $main eq "registration_landing"}User Registration - Just Hom Mens Underwear
{elseif $main eq "faqs"}Frequently Asked Questions - Just Hom Mens Underwear
{elseif $main eq "fts_sitemap"}Site Map - Just Hom Mens Underwear
{elseif $main eq "site_map"}Links - Just Hom Mens Underwear
{elseif $main eq "reviews_list"}Product Reviews - Just Hom Mens Underwear
{elseif $main eq "feedback"}Feedback - Just Hom Mens Underwear
{elseif $help_section eq "business"}Privacy Policy - Just Hom Mens Underwear
{elseif $help_section eq "about"}Delivery - Just Hom Mens Underwear
{elseif $help_section eq "returns"}Returns and Refunds - Just Hom Mens Underwear
{elseif $help_section eq "conditions"}Terms and Conditions - Just Hom Mens Underwear
{elseif $help_section eq "contactus"}Contact Just Hom
{elseif $main eq "help"}Help Section - Just Hom Mens Underwear


After the last {if} statement but if I try to input that with this i just get a blank page.

TJ Stephens 05-27-2006 10:27 PM

You should be able to add the variables for the help pages in between the {/section} and {/if} in the code below:
Code:

{elseif $config.SEO.page_title_format eq "G"}
{section name=position loop=$location}
{if %position.last%}{$location[position].0|escape}{/if}
{/section}
{INSERT OTHER IF STATEMENTS HERE}
{/if}

Let me know if that works.

cotc2001 05-29-2006 01:14 AM

Its ok I sorted it easy enough - i'll put it down to a case of being totally knackered.

One thing i've lost (which may of happend well before this) is the ability to have the page title that is entered in static pages shown - at the moment it just displays the default title of "HOM underwear" , anyone have the code to hand before I sift through the defaut x-cart distro for it.

jdedba 06-19-2006 01:27 PM

Version 4.1.1 is different. I do not see skin1/admin/configuration.tpl file. There is a configuration.tpl file in skin1/admin/main. But it does not have the code for the title format dropdown. Does anyone know where to find the code in 4.1.1?

One way to workaround is just using
Code:

<title>
{section name=position loop=$location}
{if %position.last%}{$location[position].0|escape}{/if}
{/section}
</title>

to replace
Code:

<title>
{if $config.SEO.page_title_format eq "A"}
{section name=position loop=$location}
{$location[position].0|strip_tags|escape}
{if not %position.last%} > {/if}
{/section}
{else}
{section name=position loop=$location step=-1}
{$location[position].0|strip_tags|escape}
{if not %position.last%} :: {/if}
{/section}
{/if}
</title>

in home.tpl.

Thanks for sharing.

newattraction 02-24-2007 11:09 AM

Re: Display Only Current Page in Page Title
 
For version 4.1.6, there's no need to change configuration.tpl. Just add an option "G: Current Page Only" to cell titled "page_title_format" in xcart_config table (around page 5) using phpMyAdmin, and select this option G from backend Admin.

newattraction 03-06-2007 08:54 PM

Re: Display Only Current Page in Page Title
 
Don't forget, if you use Fast Lane Checkout in version 4.1.x, this file should also be modified: \skin1\modules\Fast_Lane_Checkout\home.tpl.

mitash 03-06-2007 09:12 PM

Re: Display Only Current Page in Page Title
 
Nice mod...I would recommend Produt Meta tags and Titel Tags Plus from BCSE!

mitash 03-06-2007 09:13 PM

Re: Display Only Current Page in Page Title
 
Gives you the liberty to add cutom titles etc.... excellent for SEO


All times are GMT -8. The time now is 11:27 AM.

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