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)
-   -   Here is How to Change Page Title Tag Format (remove "::") (https://forum.x-cart.com/showthread.php?t=53332)

gallaghersean 04-17-2010 09:49 PM

Here is How to Change Page Title Tag Format (remove "::")
 
I figure I'd pass this along for anyone else wanting to know how to do this. If you want to change the format of the default :: character separator follow these instructions.

I don't know why X-Cart choose a double colon for a separator in their title tags it does not make much sense SEO-wise. The best format for the title tag is: Product Name - Category | Site Name. That is the best format for search engine according to current studies (reference: Best SEO Practices by SEOmoz).

So now on to the details... to change the format follow these steps:

For Page Titles like this: Product Name - Category - Site Name
  1. Open up the file include/templater/plugins/function.get_title.php
  2. Go to line 107.
  3. On this line you will find implode(' :: ', $tmp))); at the end of the line of code change the :: out for the - character or whatever you want. Now this will make your title tags look like this Product Name - Category - Site Name
For Page Titles like this: Product Name - Category | Site Name
  1. First make sure you have the setting in Main page :: General settings :: SEO options :: Page title format set to Product name :: Category name :: Shop name
  2. Open up the file include/templater/plugins/function.get_title.php
  3. Go to line 107.
  4. Replace that entire line
    $title = str_replace(array("\n", "\r"), array("", ""), trim(implode(' :: ', $tmp)));
    With the following:
    PHP Code:

    ############################################
    # Title Tag Hack By RocketMarketingInc.com #
    ############################################
    $title '';
    $titlePartCount count($tmp);
    $icount 1;
    foreach(
    $tmp as $titlePart)
    {
     if(
    $icount!=1) { $title .= ($icount!=$titlePartCount) ? ' - ' ' | '; }
     
    $title .= $titlePart;
     
    $icount++;
    }
    $title str_replace(array("\n""\r"), array(""""), trim($title)); 

That should do it! If you have any questions let me know.
And if you need any other help with SEO on your site feel free to contact me at RocketMarketingInc.com or the contact link in my sig.

balinor 04-18-2010 03:55 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Nice! Been meaning to tackle this one eventually as it has been driving me nuts as well. Thanks for sharing, moving this to the Custom Mods forum.

hoosierglass 04-18-2010 08:01 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
I believe this is not needed when using CDSEO Pro.

balinor 04-18-2010 08:36 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
It is for some pages not covered by CDSEO Pro

gallaghersean 04-18-2010 10:40 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
It's also good for those of us not using CDSEO Pro.

Paulw 04-29-2010 05:53 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Any idea's how to do this on 4.1.9 as include/templater/plugins/function.get_title.php doesn't exist?

Great mod by the way!

Paul

balinor 04-29-2010 06:10 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
In 4.1.9 just edit customer/home.tpl. You'll see the title tag up top.

Paulw 04-29-2010 06:11 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
I'm so thick! Many thanks

Paul

jvannghi 07-18-2010 02:33 PM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Any idea on how to remove the "::" and replace with "-" on X-Cart version 4.1.5? Thanks.

-John

ADDISON 07-19-2010 02:46 PM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
It could be inserted in General Settings. A text box for that divider.

I will suggested in 4.4

ARW VISIONS 07-19-2010 06:46 PM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Ummm, when are they going to stop using thjis for a title?

Every version since I started x-cart has had this. And I have to change it every time?

what gives!!!!

cflsystems 07-19-2010 07:15 PM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Or they should have added this in the SEO settings - easy to do it

jvannghi 07-28-2010 01:27 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Hey guys,

I can't seem to make this change in 4.1.5.

I found it in the template but would show an error after trying to save. Also nothing in General/SEO.

I'd appreciate any help!

Vacman 07-28-2010 12:40 PM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Likewise I can't get it to work for 4.3.2. I made the changes, cleared the cache, etc - and no difference.

gallaghersean 08-10-2010 11:06 PM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Hi guys,

I've been setting up 4.4 beta and thought you might want to know how to change the title tag for that. Yes they did it again - using :: in title tag again. I don't understand why they do that? Maybe we can convince them to add something in to 4.4 since it's beta so we don't have to mod it every time.

Anyways, on with the show...

My previous version instructions work for the 4.4 Beta with the exception that you are looking for the following line on 107 to edit/replace.

PHP Code:

$title str_replace(array("\n""\r"), array(''''), trim(implode(' :: '$tmp))); 


ADDISON 08-10-2010 11:20 PM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Correct. But you are now able to set up your own breadcrumb in Admin. Just check Appearence settings at the bottom in v4.4.

Also they set a language variable called $lbl_site_path, which is Home by default. I can change the name or leave it empty. This new feature will help you with the location. Home :: Category 1 :: ...

If it is empty, Home will dissapear from path.

Quote:

Originally Posted by gallaghersean
Yes they did it again - using :: in title tag again. I don't understand why they do that?


gallaghersean 08-10-2010 11:26 PM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Quote:

Originally Posted by am2003
Correct. But you are now able to set up your own breadcrumb in Admin. Just check Appearence settings at the bottom in v4.4.

Also they set a language variable called $lbl_site_path, which is Home by default. I can change the name or leave it empty. This new feature will help you with the location. Home :: Category 1 :: ...

If it is empty, Home will dissapear from path.


Yes, you can change the breadcrumb but that does not change the title tag - you still have to manually get in there and change the function.get_title.php file. Also you can't setup the title tag in this format keyword - keyword | Company Name by changing the $lbl_site_path variable. The best you can get with that is keyword - keyword - | Company Name (notice the dash and pipe before company name & the dashes are only present if you do my mod).

cosy 08-11-2010 08:51 PM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Can we add our own title?

cflsystems 08-12-2010 03:10 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
No, not with this. But you can do it with one of the following
1. Buy 3rd party SEO module like CDSEO OR
2. Use this free mod - http://www.cflsystems.com/custom-page-titles-mod-for-x-cart-shopping-cart.html OR
3. Upgrade to 4.3.2 where the above #2 is already build in

BTW I would recommend you to upgrade to at least 4.2.3 - 4.2.0 was buggy

gallaghersean 08-12-2010 07:00 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Quote:

Originally Posted by cosy
Can we add our own title?


Yes, you can use this to create your own title. You could of course have to write more PHP in order to do that and let X-Cart know which pages you want with what title tag. Thus that's why cflsystems suggested the SEO mods as it might be easier to just add one of those mods (depending on your PHP skills) than try to write a custom title tag insertion that goes by page type.

jvannghi 08-12-2010 09:08 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Quote:

Originally Posted by am2003
It could be inserted in General Settings. A text box for that divider.

I will suggested in 4.4


I'm sorry...don't quite understand. Can you clarify? I didn't see anything in general settings.

ScottW 08-04-2011 07:56 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
FYI in version 4.4.2 the variable $tmp is replaced by the variable $title_items so you have to switch out the variable in the code to make it work in 4.4.2.

kgoel 12-19-2011 09:39 PM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Quote:

Originally Posted by Vacman
Likewise I can't get it to work for 4.3.2. I made the changes, cleared the cache, etc - and no difference.


Could you get it working for 4.3.2. I have tried the changes but no difference.:-)

gallaghersean 10-18-2012 09:59 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Here is an update on how to do this for v 4.5.x

There are 2 different methods. One for just making the :: to a dash (basic) and the other is having a dash between products & categories and pipe before site name (complex).

Before doing either make sure to backup your files that are being changed and to set your Page title format in the SEO settings (Main page :: General settings :: SEO) to Product name :: Category name :: Shop name.

Basic change of :: characters to dash (-):
  1. Open up the file include/templater/plugins/function.get_title.php
  2. Go to line 152 (or around that area).
  3. On this line you will find $title = str_replace(array("\n", "\r"), array('', ''), trim(implode(' :: ', $title_items))); at the end of the line of code change the :: out for the dash - character or whatever you want.
  4. Save and re-upload to server.
  5. Now this will make your title tags look like this Product Name - Category - Site Name
Complex change of :: characters to dash for products and pipe for site name:
  1. Open up the file include/templater/plugins/function.get_title.php
  2. Go to line 152 (or around that area).
  3. Remove the following line:
    $title = str_replace(array("\n", "\r"), array('', ''), trim(implode(' :: ', $title_items)));
  4. Replace that line with the following code.
    PHP Code:

    #######################################
    # Title Tag Hack By RocketRideSEO.com #
    #######################################
    $title '';
    $titlePartCount count($title_items);
    $icount 1;
    foreach(
    $title_items as $titlePart)
    {
     if(
    $icount!=1) { $title .= ($icount!=$titlePartCount) ? ' - ' ' | '; }
     
    $title .= $titlePart;
     
    $icount++;
    }
    $title str_replace(array("\n""\r"), array(""""), trim($title)); 

  5. Save and re-upload to server.
That should do it! If you have any questions let me know.
And if you need any other help with SEO on your site feel free to contact me at RocketRideSEO.com or the contact link in my signature.

wplume 11-18-2012 10:18 AM

Re: Here is How to Change Page Title Tag Format (remove "::")
 
Balinor,

My home.tpl doesn't have any code that looks like
"$title = str_replace(array("\n", "\r"), array("", ""), trim(implode(' :: ', $tmp)));

Has anyone done this on v4.1.9?

-Wayne


All times are GMT -8. The time now is 02:58 PM.

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