Page Title in 4.2
4.2 came out with some new features including meta keywords, meta descriptions and clean url's, but QT left out something very important - PAGE TITLE. Page title is still "product name-category name-store name" or "store name-category name-product name" and there is no setting to change that. I wonder why they didn't include page title for products, categories, static pages....
Anyway here is how this can be added. Please note that this is for stores that do not have 3rd party SEO addons and is for 4.2. Please make backups to your DB and store files first 1. Add new field to xcart_products table. I called my product_page_title and is varchar(255), latin1_swedish_ci 2. Add new language variable - lbl_product_page_title with value "Product Page Title" 3. Open include/product_modify.php and find Code:
$query_data = array( Code:
"product_page_title" => $product_page_title 4. Open skin1/main/product_details.tpl and add Code:
<tr> 5. Open include/import_products.php and find Code:
$import_specification["PRODUCTS"] = array( Code:
"product_page_title"=> array() 6. Open skin1/customer/service_head.tpl and find Code:
{$html_page_title|escape} Code:
{if $product.product_page_title ne ""} Same logic can be applied to the categories changing the coresponding files |
Re: Page Title in 4.2
this is very usefull, thank you for this post. I've been thinking about something like this for a while. It always looks good in serp's when your title does not get cut off half way on a word. I've changed it up a little though.
This line of code for skin1/main/product_details.tpl , i've added a maxchar limit to where google truncates the title tag: Code:
or what would be even better than this is a char counter on the text box that would show you how many characters you have left before Google truncation, but still allowed you to make a longer title tag. |
Re: Page Title in 4.2
Yes Google picks up the first 64 characters but you can still show more in the title. That's the reason i left it without 64 character restriction. Glad someone got use of it though :)
|
Re: Page Title in 4.2
FANTASTIC mod clf! Thanks a TON for this.
Would you happen to know how to do this same thing for static pages / mind giving a quick tutorial on how to do it? Thanks again! |
Re: Page Title in 4.2
Happy it works out for you. I haven't done it for anything except product and category pages. The default x-cart way for right now works fine for my static pages so I didn't even look at the code and try to change it. I would say if you follow the same logic you will find the way. I might look at doing this a later time
|
Re: Page Title in 4.2
OK guys here it is. This mod is for stores that do not use any 3rd party SEO mods and was tested on 4.2.1. I am pretty sure it will work on 4.2 as well. Use it and/or modify it in any way you want to fit your needs, after all it is FREE, just please do not charge other people for it claiming is something you did :)
1. Backup your store and database first. Better yet try this mod on a test store and make sure it works before applying it to your live store. 2. Adding language variables. You can use myphpadmin or x-cart patch/upgrade section for this, or just add them manually in the language section Code:
3. Adding new fields for category, product, manufacturer and static pages in the corresponding tables. You can use myphpadmin or x-cart patch/upgrade section for this. Code:
ALTER TABLE `xcart_categories` ADD `category_page_title` varchar(255) Not Null 4. FOR CATEGORY PAGE TITLE open admin/category_modify.php, find Code:
Code:
open skin1/admin/main/category_modufy.tpl, find Code:
<tr> Code:
open include/import_categories.php, find Code:
define('IMPORT_CATEGORIES', 1); Code:
"category_page_title" => array() #Added by CFL Systems for category page title in the same include/import_categories.php find Code:
Code:
5. FOR PRODUCT PAGE TITLE open include/product_modify.php and find Code:
Code:
open skin1/main/product_details.tpl, find Code:
Code:
open include/import_products.php and find Code:
Code:
Continue in the next thread |
Re: Page Title in 4.2
...... from the previous thread
6. FOR MANUFACTURER PAGE TITLE open modules/Manufacturers/manufacturers.php and find Code:
Code:
Code:
Code:
open skin1/modules/Manufacturers/manufacturers.tpl, find Code:
Code:
7. FOR STATIC PAGE TITLE open admin/pages.php, find Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
open skin1/admin/main/page_edit.tpl, find Code:
Code:
Continue in the next thread |
Re: Page Title in 4.2
...... from the previous thread
8. MAKE THE NEW TITLES APPEAR open skin1/customer/service_head.tpl, find Code:
Code:
9. Run cleanup.php That's it. Hope it will work for you. It works for me. I tried to keep it clean and easy to follow. If you have trouble installing it I can do it for you. Enjoy! |
Re: Page Title in 4.2
I am having some problems with the above modifications. I have followed all steps, but now when I want to edit a product it x-cart tells me to fill in all fields. But all are already filled in.
Can anyone tell me what I do wrong? |
Re: Page Title in 4.2
What kind of errors?
|
Re: Page Title in 4.2
Quote:
When editing product: Quote:
When editing static page: Quote:
I also noticed that when updating category it says its updated, but the page title doesn't show on customer pages nor when editing the category in admin panel. |
Re: Page Title in 4.2
Non of this happens for me. Actually after your message I did all of this on my test site and got no errors. Everything works. Do you have any other modifications that might cause this? Are you sure you didn't make errors when making changes to php files?
|
Re: Page Title in 4.2
Quote:
I got it to work, instead of pasting it after: <tr> <td height="10" class="FormButton" nowrap="nowrap" valign="top">{$lng.lbl_page_name}:</td> <td><font class="Star">*</font></td> <td><input type="text" name="pagetitle" value="{$page_data.title|default:"$default_page_ti tle"}" size="45" {if $config.SEO.clean_urls_enabled eq "Y"}onchange="javascript: if (this.form.clean_url.value == '') copy_clean_url(this, this.form.clean_url)"{/if} /></td> </tr> I removed the above and pasted the new code, ofcourse x-cart cant read the names etc. then. My fault, sorry! Thanks for the mod, works fine now :) |
Re: Page Title in 4.2
Glad you got it working
|
Re: Page Title in 4.2
Anyone for 4.1.9. ?Any help !!!
Thanks to all. |
Re: Page Title in 4.2
I am afraid you either have to pay someone to try fit this mod in 4.1.9 or go with commercial mod which will probably cost the same so...
|
Re: Page Title in 4.2
I am testing 4.3 beta and QT added some idea from you Steve. Good job anyway!
|
Re: Page Title in 4.2
I knew they will have to add this feature but to actually borrow this code wow means I am on the right track. Maybe xcart should have "credits" section in admin to put all names of ppl which code, ideas or beta testing they used :)
|
Re: Page Title in 4.2
Here is another possible solution:
Passing variable title to header template When the majority of your templates use the same headers and footers, it is common to split those out into their own templates and {include} them. But what if the header needs to have a different title, depending on what page you are coming from? You can pass the title to the header as an attribute when it is included. Passing the title variable to the header template mainpage.tpl - When the main page is drawn, the title of ⌠Main Page■ is passed to the header.tpl, and will subsequently be used as the title. Code:
{include file='header.tpl' title='Main Page'} archives.tpl - When the archives page is drawn, the title will be ⌠Archives■. Notice in the archive example, we are using a variable from the archives_page.conf file instead of a hard coded variable. Code:
{config_load file='archive_page.conf'} header.tpl - Notice that ⌠Smarty News■ is printed if the $title variable is not set, using the default variable modifier. Code:
<html> This is all information that can be found in the Smarty docs. |
Re: Page Title in 4.2
I get the following error when trying to modify any category:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/*edit*/public_html/*edit*.com/admin/category_modify.php on line 199 Here's what the file in question looks like, starting at line 189: Code:
# Update general data of category Line 199 is the added Code:
"category_page_title" => $category_page_title Any suggestions? |
Re: Page Title in 4.2
You have to have comma after each element of the array except for the last one. Put comma after
Code:
"override_child_meta" => $override_child_meta |
Re: Page Title in 4.2
Thanks!
Now I have to go back and add commas to the rest of the .php files =( But at least I know what's wrong and how to fix it. I was afraid I'd have to go back and undo all the changes I just made. Again, thanks, both for your addressing my question and also for this modification. |
Re: Page Title in 4.2
Oops, sorry, never mind, I was responding to second page of thread not seeing it had already been answered on 3rd page.
|
Re: Page Title in 4.2
Apparently I have messed up the import_categories.php file as well. I get the following error when trying to reach the import page:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /public_html/*edit*.com/include/import_categories.php on line 78 Here is my code, hopefully I included enough of it for assistance. Code:
if (!defined('IMPORT_CATEGORIES')) { Line 77, 78, and 79: Code:
"category_page_title" => array() #Added by CFL Systems for category page title Thanks, |
Re: Page Title in 4.2
You need comma (,) after "category_page_title" => array()
When I wrote that mod "category_page_title" => array() was the last call in the array. It look like for 4.2.2 they have added more elements into the array. Remember - array elements are separated by comma (,), no comma after the last one |
Re: Page Title in 4.2
Thank you. I have added a comma (see code below), but now get the same error for line 84. I guess I'm having trouble finding where to add/remove commas. I've added/removed them from a few different places now and each time gives me an error on a different line.
Code:
define('IMPORT_CATEGORIES', 1); Line 83, 84, 85: Code:
"export_tpls" => array( |
Re: Page Title in 4.2
I did not see this in when I answered before. It seems like my original instructions are not easy to follow, sorry. You are adding the code in the wrong place. It is not supposed to go right after
Code:
$import_specification["CATEGORIES"] = array( Code:
"icon" => array( so the code will look like this Code:
....................... |
Re: Page Title in 4.2
Still getting:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /public_html/*edit*.com/include/import_products.php on line 84 Code: Code:
define('IMPORT_CATEGORIES', 1); |
Re: Page Title in 4.2
Attach the entire import_categories.php file here. You may need to rename it to .txt or something else
|
Re: Page Title in 4.2
1 Attachment(s)
Here it is. Thank you for looking into this.
|
Re: Page Title in 4.2
1 Attachment(s)
I couldn't see what's wrong - this is the stock xcart file with the line for the hack added. Try it
|
Re: Page Title in 4.2
I uploaded your file and crossed my fingers; still getting an error on line 84.
|
Re: Page Title in 4.2
What would it do if I took out the two bits of extra code, but left the additions in all of the other files?
|
Re: Page Title in 4.2
Restore the original file and see what happenes.
import_categories.php affects only the import/export process |
Re: Page Title in 4.2
Argh, I got it finally. I was seeing the same error, but if I bothered to actually read, the import_categories.php was fixed but the comma addition, however, the line 84 error was in the import_products.php file, which now has a comma added as well. Everything seems to be working thus far, at least I'm able to reach the desired page. Thanks for your help!
|
Re: Page Title in 4.2
Just installed this mod and it works great!
|
Re: Page Title in 4.2
Did 4.2.3 fix this? I read the manual, but it isn't clear if there was a change made.
|
Re: Page Title in 4.2
No this is not present in 4.2.x
It will be in 4.3 as far as I know |
Re: Page Title in 4.2
Thank you very much for this great mod!! It works great in 4.2.2
|
Re: Page Title in 4.2
I have installed this mod and it works great for Manufactures and Products.
For categories, I do see the new input box on the category modify page. When I hit update after adding a title, I get the message that the chages have been saved. But the category page title was reset to empty page field and nothing got saved. I double checked all the changes and everything seems to be there. Any ideas what I could be missing? |
All times are GMT -8. The time now is 12:08 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.