X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   page title info in 4.4.x (https://forum.x-cart.com/showthread.php?t=56149)

upupcreative 10-22-2010 09:48 AM

page title info in 4.4.x
 
Hello. I've noticed that in my 4.4.x shop and others I've seen so far, they all have the same default page title (Home) as opposed to having the shop name as the default. I've tried service_head.tpl and the language labels and a few other things but I can't seem to figure out where this "home" label is coming from and how I can switch it to my shop name.

See http://www.upupcreative.com/product.php?productid=190485&cat=403&page=1 for example, where the page title SHOULD be Up Up Creative :: This Month's Picks :: 2011 Illustrated (etc...)

Thanks,
Julie

PhilJ 10-22-2010 09:50 AM

Re: page title info in 4.4.x
 
Try General Settings > SEO

upupcreative 10-22-2010 09:53 AM

Re: page title info in 4.4.x
 
I did try that also and it sort of worked. If I enter Up Up Creative as my default "title" tag on the SEO settings page you directed me to, it replaces everything from service_head.tpl so that every single page just has Up Up Creative without any additional category or product title info.

cflsystems 10-22-2010 06:58 PM

Re: page title info in 4.4.x
 
Isn't it fun that QT still can't get the SEO right

james elliott 10-23-2010 01:12 PM

Re: page title info in 4.4.x
 
It would be great if someone could answer this? SEO in the cart's admin is crap if you use a site title the title is all that shows no products at all anyone?

upupcreative 10-25-2010 09:51 AM

Re: page title info in 4.4.x
 
someone at QT let me know that this bug is being fixed. not sure when but at least it's coming...

peddler 10-25-2010 12:39 PM

Re: page title info in 4.4.x
 
The "Home" field is set deep within the php files and prolly shouldn't be changed. It may have implications in other functions, like the clean url function. While waiting for xcart to get out a patch..

A small change can be made to the function.get_title.php file in the /include/templater/plugins/ directory and "Home" will turn into your domain name. At line #120 is this:


Code:

// truncate
    $title = str_replace(" ", " ", $title);
    if (strlen($title) > $config['SEO']['page_title_limit'] && $config['SEO']['page_title_limit'] > 0) {
        $title = func_truncate($title, $config['SEO']['page_title_limit']);
    }



Insert this after the first line of code:

Code:

// title mod
$title = str_replace("Home", "Your Domain Name", $title);
// end title mod



Thus:

Code:

// truncate
    $title = str_replace(" ", " ", $title);

// title mod
$title = str_replace("Home", "Your Domain Name", $title);
// end title mod


    if (strlen($title) > $config['SEO']['page_title_limit'] && $config['SEO']['page_title_limit'] > 0) {
        $title = func_truncate($title, $config['SEO']['page_title_limit']);
    }


You can put whatever text you want in place of "Your Domain Name". e.g. "The Donut Hole - the hole truth and nothing but!" But it will show as part of the title on EVERY page!

===============

The line of code immediately above the "//truncate" comment is this:

Code:

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

That is what sets the separator between categories and "Home" (which will now have your domain name title!). That ' :: ' has the two colons (whaaat?), with a blank space on each side. You can change it to a hyphen, with or without a space on the sides.

peddler 10-25-2010 01:26 PM

Re: page title info in 4.4.x
 
A little more complicated...

I set the title and meta data on the admin page (or in the import file) for all of my categories, products and static pages. This took care of all the pages that I use (don't use manufacturer) except for some of the help pages, cart pages and other buyer account pages. So I came up with a mod for them. Then I realized that the mod took care of the category, product and static page titles as I'd input them.. individually, painstakingly, input each and every one within the import file or admin page. Oh well :-)

What the mod does: it strips out any string of categories or help zone layers so that only the last one is in the title, with the domain name first. Supposedly this is good for SEO - short and sweet. These:

Home :: Help Zone :: Contact Us
Home :: Profile Details :: Checkout
Home :: Large Widgets :: Red Widgets :: Older Widgets :: Refurbed Widgets
Home :: Large Widgets :: Red Widgets :: Older Widgets :: Refurbed Widgets :: Widget 228

Become these:

YourDomainName - Contact Us
YourDomainName - Checkout
YourDomainName - Refurbed Widgets
YourDomainName - Widget 228

Large segments of code are shown below (for reference), but only the bolded parts need be exchanged. And be sure to use your actual domain name in place of "Your Domain Name".

Original code (from function.get_title.php file, about line 120~):

Code:

// Title based on bread crumbs
        $location = $smarty->_tpl_vars['location'];
        $tmp = array();
        if ($config['SEO']['page_title_format'] != 'A')
            $location = array_reverse($location);

        foreach ($location as $v) {
            $tmp[] = $v[0];
        }

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

    // truncate
    $title = str_replace(" ", " ", $title);

    if (strlen($title) > $config['SEO']['page_title_limit'] && $config['SEO']['page_title_limit'] > 0) {
        $title = func_truncate($title, $config['SEO']['page_title_limit']);
    }

    // escape


Modded code:

Code:

// Title based on bread crumbs
        $location = $smarty->_tpl_vars['location'];
        $tmp = array();
        if ($config['SEO']['page_title_format'] != 'A')
            $location = array_reverse($location);

        foreach ($location as $v) {
            $tmp[] = $v[0];
        }

        $title = end($tmp);


    // truncate
    $title = str_replace(" ", " ", $title);
 
if ($title == 'Home') {
    $title = str_replace("Home", "Your Domain Name", $title); } else {
    $title =  'Your Domain Name - ' . trim($title);
  }
    }


    if (strlen($title) > $config['SEO']['page_title_limit'] && $config['SEO']['page_title_limit'] > 0) {
        $title = func_truncate($title, $config['SEO']['page_title_limit']);
    }

    // escape



Or you can wait on the xcart patch and hope for the best. This one I don't want nor need, but a patch for OPC and the address book.. now THAT I need! :wink:

james elliott 10-25-2010 04:41 PM

Re: page title info in 4.4.x
 
You the man , worked for me far as I can tell. X-cart needs to give you a job since they can't seem to figure it out..lol

upupcreative 10-29-2010 04:59 PM

Re: page title info in 4.4.x
 
I haven't gotten to your second mod, Peddler, but the first one was so nice and quick and easy. I appreciate your help - that's exactly what I needed.

Julie

digiemp 10-31-2010 02:34 PM

Re: page title info in 4.4.x
 
Quote:

Originally Posted by peddler
You can put whatever text you want in place of "Your Domain Name". e.g. "The Donut Hole - the hole truth and nothing but!" But it will show as part of the title on EVERY page!


Is there a way to add something to every page EXCEPT the home page?

I have the home page title as I want it. But the product or category page titles are simply "Product" or "Category" where "Product" is the actual name of the product in question. I can alter the category title and force that on every product in the category, but that's not really the proper solution.

What I would like is to be able to hard code part of the title tag to appear after whatever title I type into the appropriate text box under SEO Options.

So if on the 'glazed doughnut' page the title would read "Glazed Doughnut - Doughnuts.com". Or if in the 'cream filled' category the page title would read "Cream Filled - Doughnuts.com" or whatever. Currently if on the 'glazed doughnut' page the title is simply "Glazed Doughnut".

My site that used 4.1.8 did this with no additional coding so I know it is possible.

peddler 11-01-2010 10:03 AM

Re: page title info in 4.4.x
 
Quote:

My site that used 4.1.8 did this with no additional coding so I know it is possible.

Yeah, but 4.1.8 used a simple coding technique within the home.tpl file. With 4.4.1, there's a whole different approach, not the least of which is the 7KB file, function.get_title.php. Are you looking to do this without "additional coding", cuz you also wrote "I would like is to be able to hard code" ?? I'm a bit confused on that. It will take a coding change to make what you want.

Quote:

I have the home page title as I want it.

How did you do that? Did you hard-code a tpl file? If so, then a code change to the function.get_title.php file shouldn't affect your home page title. I can't say for certain without knowing how you coded it.

Refer to my post #1 and instead of using this line of code:

Code:

$title = str_replace("Home", "Your Domain Name", $title);


Use this:

Code:

$title = trim($title) .' - Your Domain Name' ;


Format that bit, - Your Domain Name , however you wish; whatever you want to put between the single-quote marks. (remember to verify that your home page title is un-changed)



Your final code will look like this:

Code:

    // truncate
    $title = str_replace(" ", " ", $title);

  // title mod
    $title = trim($title) .' - Your Domain Name' ;
  // end title mod


    if (strlen($title) > $config['SEO']['page_title_limit'] && $config['SEO']['page_title_limit'] > 0) {
        $title = func_truncate($title, $config['SEO']['page_title_limit']);
    }

    // escape


digiemp 12-08-2010 09:14 PM

Re: page title info in 4.4.x
 
Okay, I finally got around to doing this. It definitely works, but it changes EVERY page, including the homepage. It is probably fine to add it to the homepage as well but I thought you should know the outcome.

Thanks again.

peddler 12-09-2010 11:05 AM

Re: page title info in 4.4.x
 
Quote:

Originally Posted by digiemp
Okay, I finally got around to doing this. It definitely works, but it changes EVERY page, including the homepage. It is probably fine to add it to the homepage as well but I thought you should know the outcome.

Thanks again.



Look back over post #8, it checks for the Homepage and allows its title to be whatever you want it to be, and then you can set the title for all other pages.

I understood you to want the categories and product page titles to show their name first, followed by your domain name - that would be the opposite of the layout shown in post #8. To get what you want, just use the code I gave in my previous post and include it in post #8's code. Like this:

Code:

$title = end($tmp);


    // truncate
    $title = str_replace(" ", " ", $title);
  if ($title == 'Home') {
    $title = str_replace("Home", "Your Domain Name", $title); } else {
    $title = trim($title) .' - Your Domain Name' ;
  }
    }


If that isn't what you meant, then I'm confused. And it won't be the first time for that! :D

.

proboscidian 03-16-2011 08:12 AM

Re: page title info in 4.4.x
 
One of my customers just asked me to generate titles and descriptions like this:

TITLE
Manufacturer - SKU - Category - Company

DESCRIPTION
COMPANY has been serving the electrical industry since 1992. Low prices. Purchase SKU today! With over 30 years providing MANUFACTURER products and others we can help with your CATEGORY needs (etc. etc., there is a lot of garbage text to insert)

Any idea on how to do this?


All times are GMT -8. The time now is 01:46 AM.

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