Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
Forum Search
Google Site Search
 All Forums
 Technical
 Tips and Tricks - HALL OF FAME
 Revised PHP Dynamic Title + Meta Description code
Next Page
Author « Topic »
Page: of 2

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 03/23/2015 :  01:00:17  
Having carefully studied the very important Ecommerce Templates PHP Help page here about automatically generating Dynamic Page Title and Description tags for Menu Categories, Products and Product Detail pages, after experimenting, I am not sure that those instructions are the best way to go.

So can I please start a Thread explaining alternative dynamic PHP code that works for me.

But more importantly, please do add your comments suggesting improvements to the code below. And that way we can all get it right !

For ASP users, sorry I don't work with that, but others who do will be able to convert.

Should mention I use Adobe Dreamweaver CS6 to design the Template and generate all necessary website pages from that.

Gary

Edited by - ITZAP on 03/23/2015 03:59:12

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 03/23/2015 :  01:08:51  
UPDATED Monday, 29th January 2018.

Please note that all the code that I posted previously has now been revised.

For users of the fantastic “Ecommerce Templates” PHP shopping cart software, there is now a WinZip file available to download FREE here containing HTML and PHP code snippets to generate dynamic <title>, <meta description> and <meta og: tags> in your website page code.

Once you have downloaded and UnZipped the file, please open the “00-ect-dynamic-code-readme.pdf” file which explains all, along with details on my website page.

The HTML and PHP code is provided “as is” and was written using Adobe Dreamweaver CC 2015.

Gary

Edited by - ITZAP on 02/01/2018 19:17:27

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 03/23/2015 :  01:18:49  
Do you have dynamic code for the ASP and Wordpress versions ?

No, sorry. I do not work with those versions. This is a task that somebody else in the Ecommerce Templates community might kindly provide.

Gary

Edited by - ITZAP on 07/14/2017 01:42:28

Judytu
Ecommerce Template Guru

USA
2483 Posts

Pre-sales questions only
(More Details...)

Posted - 07/10/2015 :  12:27:57  
So, here I am just posting about this og tags, and find all of this timely and useful information. Unfortunately, I don't fully understand all of it so I have some questions. . .

Is ALL of the code as posted necessary to add to each of the pages listed? I only want the thumbnail used on each social media post - so would I only add to the products page?

It looks like all images need to be titled the same as the page, i.e., NCKFB1.jpg = http://www.streepwear dot com/proddetail.php?prod=NCKFB1. Is this correct?

I have many other questions, but let's start here.

Thanks!

~ Judy

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 07/10/2015 :  20:48:39  
quote:
Unfortunately, I don't fully understand all of it
Well yes, it does get somewhat complex I suppose. For those who would like all this dynamic code implemented on their website, I am happy to do it all for you.

Simply send me an email with these files attached :
(1) includes.php
(2) categories.php
(3) products.php
(4) proddetail.php
(5) Business Name, website URL, brief explanation about what you sell. (Refer to Post No 2 at top of page.)
(6) Facebook ID, Twitter ID, if you have those social pages.

I will make the code alterations and send you back the revised files for upload to your web server (FTP access preferred). And all will be good.
My price is Australian AUD$75.00 with payment via PayPal.

Gary

Edited by - ITZAP on 10/02/2016 20:20:02

Judytu
Ecommerce Template Guru

USA
2483 Posts

Pre-sales questions only
(More Details...)

Posted - 07/10/2015 :  21:22:26  
Gary, thanks for all of this...and I may just take you up on your offer to install all of this code onto my site. But, I have to take care of "image.jpg" matching the product name...YIKES!!

~ Judy

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 07/10/2015 :  21:40:17  
Goodaye Judy,
Please note that the <meta property="og:image"> tag is optional. If too much trouble to update, it can be omitted.
But nice to have because good photo in Facebook or Twitter post is what attracts attention, what gets clicks and visitors to your website.

And my suggestion about entering Product ID that describes-what-the-feature-photo-is, that is optional also. So long as Product ID exactly matches any one .jpg photo filename, then it will work.
Note : If your photos have uppercase .JPG extension across entire site, then the "og-image" code entry would need to be altered accordingly.

Gary

Edited by - ITZAP on 07/10/2015 21:53:55

Judytu
Ecommerce Template Guru

USA
2483 Posts

Pre-sales questions only
(More Details...)

Posted - 07/10/2015 :  21:57:09  
Hi again,

I would do all of this BECAUSE of the og: tag for social media!

~ Judy

robii1
Ecommerce Template Expert

United Kingdom
510 Posts

Pre-sales questions only
(More Details...)

Posted - 06/25/2016 :  13:12:35  
Hi Gary

Really appreciate the time and efforts you've put in with this and I'm trying to implement the code on my site but have run into a problem with the title tag

I was using the following for the title on my products.php pages:

<title>
<?php
if($topsection != "") print $topsection . ", ";
print $sectionname?>
</title>

This produced the category name as the page title, which is desired. However, when I implement your code the page title comes up as "Mobile phone replacement screens, spare parts, accessories", which is what I entered for $allpagestitle in my includes.php file.

The description tag is working as expected.

I'm on the latest version, 6.5.5

Any ideas?

robii1
Ecommerce Template Expert

United Kingdom
510 Posts

Pre-sales questions only
(More Details...)

Posted - 06/25/2016 :  15:01:28  
Also, I have a question about canonical.

For example, this page with the reviews URL http://www.formymobile.co.uk/microsoft-lumia-535-touch-screen-digitizer&review=all&ro=2

I assumed the canonical link would show in the page source as:

<link rel="canonical" href="http://www.formymobile.co.uk/microsoft-lumia-535-touch-screen-digitizer">

But it's showing as

<link rel="canonical" href="http://www.formymobile.co.uk/microsoft-lumia-535-touch-screen-digitizer&review=all&ro=2">

Is that right or wrong?

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 06/25/2016 :  20:37:52  
Hi robbi1,

products.php

Please note that I UPDATED the code there on 25 June 2016 : Alterations to include Manufacturer <title>, <meta description> and <H1> heading.

So please go back and insert that code into your products.php page.

Also, I honestly don't consider their is any positive benefit in having the products.php pages indexed by search engines. The multi-page content there changes frequently and is merely duplicate information of that contained in more explicit detail on your proddetail.php pages.
And if you have a manufacturers.php page, then there will be a stack more products.php pages generated; all the same duplicate stuff yet again, just ordered differently.

Make it simple for search bots to index your site properly, as you want.
<meta name="robots" content="noindex, follow">
That instructs bots to follow links through to each of your proddetail.php pages, index that content (as a priority over the products.php content), and list those proddetail.php Titles and Short Descriptions in search results.
That is what I do and recommend.

proddetail.php

I looked at the proddetail.php URL you posted, went to Reviews tab and clicked (Show All).
The page URL then includes the extension "?review=all"
But the canonical URL entry does not. All looks good to me.

Gary

Edited by - ITZAP on 06/25/2016 21:21:04

robii1
Ecommerce Template Expert

United Kingdom
510 Posts

Pre-sales questions only
(More Details...)

Posted - 06/26/2016 :  03:20:02  
Hi Gary, thanks for the reply. You're right, the canonical tag is working on the product details page, but I've still got a problem with the products pages.

I've added the following to products.php:

<?php $pno = (isset($_GET['pg']) && is_numeric($_GET['pg'])) ? (int)$_GET['pg'] : 1; $pagenumber = ' page ' . $pno; ?>

<title><?php
if(!empty($pagetitle) && $pno == 1) {print $pagetitle;}
else if(!empty($pagetitle) && $pno != 1){print $pagetitle . $pagenumber;}
else if(!empty($topsection) && $pno == 1) {print $sectionname . ' at ' . $sitename;}
else if(!empty($topsection) && $pno != 1) {print $sectionname . ' at ' . $sitename . $pagenumber;}
else if(!empty($manname) && $pno == 1) {print $manname . ' at ' . $sitename;}
else if(!empty($manname) && $pno != 1) {print $manname . ' at ' . $sitename . $pagenumber;}
else if($pno == 1) {print $allpagestitle;}
else {print $allpagestitle . $pagenumber;} ?></title>

<meta property="og:title" content="<?php
if(!empty($pagetitle) && $pno == 1) {print $pagetitle;}
else if(!empty($pagetitle) && $pno != 1){print $pagetitle . $pagenumber;}
else if(!empty($topsection) && $pno == 1) {print $sectionname . ' at ' . $sitename;}
else if(!empty($topsection) && $pno != 1) {print $sectionname . ' at ' . $sitename . $pagenumber;}
else if(!empty($manname) && $pno == 1) {print $manname . ' at ' . $sitename;}
else if(!empty($manname) && $pno != 1) {print $manname . ' at ' . $sitename . $pagenumber;}
else if($pno == 1) {print $allpagestitle;}
else {print $allpagestitle . $pagenumber;} ?>">

But now all my products pages have the exact same title:

"Mobile phone replacement screens, spare parts, accessories" (which is what I entered for $allpagestitle in my includes.php file) instead of their category name

Have a look here, for example - http://www.formymobile.co.uk/products.php?cat=2

Edited by - robii1 on 06/26/2016 03:23:14

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 06/26/2016 :  18:42:08  
robii1, this code works across all websites I have built.

But in your breadcrumbs, Home goes to index.php ? There is no link to categories.php ? Something different about your config ? Is that :

$orhomeurl="index.php";

I always create a Menu Category named (for example) "Menu" or "Departments", then tick the box that says : Check to make this category the product catalog root.

But I am betting that all your Menu Categories are Sub Category Of : Home Category ? Is that right ?

Gary

Edited by - ITZAP on 06/26/2016 18:53:42

robii1
Ecommerce Template Expert

United Kingdom
510 Posts

Pre-sales questions only
(More Details...)

Posted - 06/26/2016 :  19:20:27  
To create a category I simply go to admin categories, click new and leave the default settings, so yes, all my categories are sub categories of the home category.

I never understood the need for another level of pages in addition to the products and product detail pages, it just seemed like more clicks before the user arrived at the product details page, so I don't use category pages

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 06/27/2016 :  02:58:30  
OK then, on products.php, can you confirm for me that this code comes before the <title> code ?
<?php
session_cache_limiter('none');
session_start();
ob_start();
include "vsadmin/db_conn_open.php";
include "vsadmin/inc/languagefile.php";
include "vsadmin/includes.php";
include "vsadmin/inc/incfunctions.php";
include "vsadmin/inc/metainfo.php"; ?>
And if the answer is Yes, then please try this code, with the line alterations in red ...

========================================
CODE DELETED. Gary got it wrong.
========================================

Gary

Edited by - ITZAP on 06/28/2016 04:44:32

robii1
Ecommerce Template Expert

United Kingdom
510 Posts

Pre-sales questions only
(More Details...)

Posted - 06/27/2016 :  03:28:39  
Unfortunately that leaves me with a blank page, so I've reverted to the following for now:

<title><?php
if($topsection != "") print $topsection . ", ";
print $sectionname?></title>

The code has been useful for me in any case as I came across it searching for info about avoiding duplicate content. So I appreciate the time you've put in and hopefully I've solved the problem I was originally trying to solve

Edited by - robii1 on 06/27/2016 05:08:04

ITZAP
Ecommerce Template Guru

Australia
1017 Posts

Posted - 06/28/2016 :  04:49:09  
Sorry about that robii1.

If you go back top Page 1 of this Topic and look at the post about products.php, the UPDATED code there I have tested and positively confirmed works.

Gary

lrose
Advanced Member

USA
162 Posts

Pre-sales questions only
(More Details...)

Posted - 08/30/2016 :  08:14:13  
You all have my head spinning. Looks like I need professional help.
I don't think with all of the changes and revisions, I will every get this right.
Laurie

Phil
ECT Moderator

United Kingdom
7679 Posts

Posted - 08/30/2016 :  10:18:37  
Hi laurie,
If you you'd like to send me your FTP details I'll sort it out for you. Shouldn't take me longer than 10 minutes.

Just send them to phil at bettapages dot com



* Database Migrations and Conversions*
* ASP to PHP Cart Conversions*

*Contact Us*
*Buy The PHP Capture Card Plugin*
*Rate Our Services/View Our Feedback*

copiers
Advanced Member

158 Posts

Pre-sales questions only
(More Details...)

Posted - 12/22/2016 :  10:16:57  
Hello,

I was following the chain and in the end I lost it. Could you please share the title and description meta tag on products.php and categories.php page?

Thank you,

Mo

Steved
Ecommerce Template Guru

United Kingdom
1022 Posts

Pre-sales questions only
(More Details...)

Posted - 01/25/2017 :  00:12:50  
Hi Gary,

I have an issue with duplicate meta whenever I create subcategories.

For example, I have a category called Jewellery to which other categories can be added. However, GWT flags duplicate meta title and description:

/category/Jewellery
/products/Jewellery

The reason for this seems to be that although the only url I expected was category/Jewellery, ECT also adds 'All Products' to the breadcrumbs, which is the sum of all products of the subcategories and points to an additional url of products/Jewellery.

I'm struggling to think of a way round this as I don't want to disable breadcrumbs but I need to stop the 'All Products' situation where I use subcategories, or find a way to force different meta for these urls.

Steve

V6.6 + seo friendly urls

Page: of 2 « Topic »  
Next Page
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.05 seconds. Snitz Forums 2000