Forums / All Other Contributions/Addons / Meta_tag_fbtitle - Facebook Addon

Meta_tag_fbtitle - Facebook Addon

Started by sethf on 6 Dec 2011, 9:17 AM · Views: 5,037

Results 1 to 20 of 29
6 Dec 2011, 9:17 AM
#1
sethf avatar

sethf

Zen Follower

Join Date:
Sep 2011
Posts:
228
Plugin Contributions:
0

Meta_tag_fbtitle - Facebook Addon

Hi

When ever one posts a link, that is not a product page on Zen-Cart, to facebook (for example the home page of your website), instead of Facebook showing the title of your website (or the title of the page), it shows "META_TAG_FBTITLE"

I have seen another thread asking about this problem, but no proper solution was given.

Is there a solution to this problem?

Thanks for your help.
S

Edit:

Facebook will be getting the info from here:

/home/pcselect/public_html/includes/modules/meta_tags.php

Line #285 : define('META_TAG_FBTITLE', str_replace('"','',zen_clean_html($product_info_metatags->fields['products_name'])));

How can we add the title of other pages to this?

6 Dec 2011, 10:00 AM
#2
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Meta_tag_fbtitle - Facebook Addon

I suspect that you are using a mod for a facebook like button? The mod may be called 'facebook like button'? Just guessing....

If so you have added this line, and others to your html_header.php file

 <meta property="og:title" content="<?php echo META_TAG_FBTITLE; ?>"/>

As you noted this only works for product pages, Personally I don't see the reason not to just use:

 <meta property="og:title" content="<?php echo META_TAG_TITLE; ?>"/>

which just uses the page title meta tag for the og:title. Perhaps someone with more knowledge of facebook can explain why that is a bad idea? If not then I would just use that.

Having said that you could edit the meta_tags.php file that this module uses to set the META_TAG_FBTITLE to it's choice for product pages and to the META_TAG_TITLE for all the other pages.

Nick
iszent.com

6 Dec 2011, 11:22 AM
#3
sethf avatar

sethf

Zen Follower

Join Date:
Sep 2011
Posts:
228
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

niccol:

I suspect that you are using a mod for a facebook like button? The mod may be called 'facebook like button'? Just guessing....

If so you have added this line, and others to your html_header.php file

<meta property="og:title" content="<?php echo META_TAG_FBTITLE; ?>"/> ``` > > As you noted this only works for product pages, Personally I don't see the reason not to just use: > > ``` <meta property="og:title" content="<?php echo META_TAG_TITLE; ?>"/> ``` > > which just uses the page title meta tag for the og:title. Perhaps someone with more knowledge of facebook can explain why that is a bad idea? If not then I would just use that.

This worked like a charm.

Having said that you could edit the meta_tags.php file that this module uses to set the META_TAG_FBTITLE to it's choice for product pages and to the META_TAG_TITLE for all the other pages.

I am not sure what you mean here, or why this is necessary.

Thanks again.

6 Dec 2011, 12:31 PM
#4
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Meta_tag_fbtitle - Facebook Addon

SethF:

This worked like a charm.

I am not sure what you mean here, or why this is necessary.

Thanks again.

Well, for whatever reason the author of the module decided to use something other than the obvious page title. I do not claim to be a facebook expert so cannot comment about why that is, or is not, a good idea. If you wanted to follow their procedure then you'd have to alter the meta-tags.php file that they include in their module so that it produces alternate og:title tags for all pages rather than just for the product_info pages.

As I say, I personally think that the page title is the obvious choice here. But there may be facebook, or possibly SEO, reasons why you'd want to use something else instead. If someone can come up with a persuasive argument then it is probably worth listening to.

Until then I'd stick with what you have now.

Nick
iszent.com

29 Dec 2011, 2:31 PM
#5
serious avatar

serious

Totally Zenned

Join Date:
Feb 2011
Posts:
686
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

I've got the same issue....but not on every link that i add to my FB page. Weird...

I've edited my html_header.php as shown above but I still get the darn "META_TAG_FBTITLE" on some links I try to put on my FB pag, others it shows the page or product title.

Any other suggestions?

29 Dec 2011, 2:41 PM
#6
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Meta_tag_fbtitle - Facebook Addon

You need to post a URL for the site. Without that it is almost impossible to comment.

Also if you wanted to zip your html_header.php file and attach it to a post then that would help people help you.

Nick
iszent.com

29 Dec 2011, 2:45 PM
#7
serious avatar

serious

Totally Zenned

Join Date:
Feb 2011
Posts:
686
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

seriousoffroadproducts.com

And while your there....BUY SUMTHIN'!!!

:P

29 Dec 2011, 2:52 PM
#8
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Meta_tag_fbtitle - Facebook Addon

Well what does it say in the file html_header.php? In your active template. So the file will be

includes/templates/darkness/common/html_header.php

I am guessing that you have this line:

<meta property="og:title" content="<?php echo META_TAG_FBTITLE; ?>"/>

If so then change it as described in my earlier post.

Nick
iszent.com

29 Dec 2011, 2:55 PM
#9
serious avatar

serious

Totally Zenned

Join Date:
Feb 2011
Posts:
686
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

I did just as you described. Still seeing the same thing though.

I even went thru every html_header.php file (custom templates, etc) and made the same change.

29 Dec 2011, 3:29 PM
#10
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Meta_tag_fbtitle - Facebook Addon

Well the code is appearing fine in your pages.

But you do have a problem with the og:image tag which appears to be messing things up for you.

You can use http://developers.facebook.com/tools/debug to see what I mean.

As this isn't my mod, and I don't use it (instead I just wrote my own version of it ) , I can't really comment about why that is happening with this mod.

What I do is add this line into the html_header.php file

<!--Add OG tags-->
<?include(DIR_WS_MODULES . zen_get_module_directory('og_tags.php'));?>

which just includes a module in that spot. I tend to put it under the generator meta-tag.

Then in the modules folder ( either in default or in your template or both ) I put the file that is in the attachment.

Then I upload a image to use as the default og:image to the images folder. It needs to be called og_logo.jpg.

That seems to work pretty well for me. Of course, you'd want to remove the alterations that the previous mod had made to html_header.php.

All that does is write the og:tags the way I want. I think that there are other things the previous module does - so you either need to leave those bits alone or recode them. What that means is use the rest of the previous module and just use my version to load the og:tags into the header.

Nick
iszent.com

29 Dec 2011, 3:42 PM
#11
serious avatar

serious

Totally Zenned

Join Date:
Feb 2011
Posts:
686
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

Thanks for the FB debug link.
I entered a URL that I've tried to add to my FB page and this is what I get back:

Object Invalid Value: Object at URL 'http://www.seriousoffroadproducts.com/index.php?main_page=index&cPath=419_420_1172' of type 'product' is invalid because the given value 'META_TAG_FBIMG' for property 'og:image:url' could not be parsed as type 'url'.
Missing Required Property: The og:url property is required, but not present.
Missing Required Property: The og:type property is required, but not present.
Missing Required Property: The og:title property is required, but not present.

I'm going to re-read your prior response a dozen times or so, but to be honest I'm in way over my head here.

29 Dec 2011, 4:46 PM
#12
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Meta_tag_fbtitle - Facebook Addon

What your pages ( that are not product pages) og:tags look like is this:

 <meta property="og:title" content="Air Filters : Serious Offroad Products, To get there, you need to Get Serious"/>
    <meta property="og:site_name" content="Serious Offroad Products"/>
    <meta property="og:image" content="META_TAG_FBIMG"/>
     <meta property="og:url" content="http://www.seriousoffroadproducts.com/index.php?main_page=index&cPath=411"/>
     <meta property="fb:admins" content="208325602516920"/>
    <meta property="og:type" content="product"/>

You can see that where there should be a link to an image it instead says META_TAG_FBIMG. This is what is causing the errors. It is a flaw to the module, I think.

So, I don't use the module. Because it works fine for product_info pages but everything else it messes up.

So, I instead use my version, which involves a single line added to the html_head.php file and a file uploaded to the modules folder.

Nick
iszent.com

13 Jan 2012, 3:32 AM
#13
metalomania avatar

metalomania

New Zenner

Join Date:
Jan 2012
Posts:
1
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

Just had this same issue and 2 minor changes to the html_header.php file fixed it. On the 2 lines below, remove the "FB":

<meta property="og:title" content="<?php echo META_TAG_**FB**TITLE; ?>"/>
<meta property="og:image" content="<?php echo META_TAG_**FB**IMG; ?>"/>

13 Jan 2012, 3:46 AM
#14
serious avatar

serious

Totally Zenned

Join Date:
Feb 2011
Posts:
686
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

Metalomania:

Just had this same issue and 2 minor changes to the html_header.php file fixed it. On the 2 lines below, remove the "FB":

<meta property="og:title" content="<?php echo META_TAG_**FB**TITLE; ?>"/>
<meta property="og:image" content="<?php echo META_TAG_**FB**IMG; ?>"/>Just tried it on my html_header.php file (public_html/includes/templates/darkness/common) and still get the same thing.

Didn't work for me.

13 Jan 2012, 10:31 AM
#15
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Meta_tag_fbtitle - Facebook Addon

It is because you need to define what META_TAG_FBIMG is. Or define what META_TAG_IMG is. If it is undefined you will get an error.

The little bit of code I posted earlier sets it to the product image on the products pages and sets it to a default image ( which you need to upload to the images folder) for all other pages. Which is the way I like it to work.

If you just want to use a default image the whole time then you'd have

<meta property="og:image" content="path_to_image"/>

Where path_to_image might be something like http://www.mydomain.com/images/my_default_og_image.jpg.

Nick
iszent.com

3 May 2012, 4:34 PM
#17
gabstero avatar

gabstero

Zen Follower

Join Date:
Nov 2007
Posts:
342
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

gopinathgoswami:

META_TAG_FBTITLE issue is fixed. Please take a look at this contribution: http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=2026

Regards

Unfortunately I still get that META_TAG_FBTITLE showing up whenever I try to post a category page on my FB wall. I checked the source and strangely the title there looks ok. Do you know why or from where do I still get that mysterious META_TAG_FBTITLE?

thanks,
gabstero

4 May 2012, 3:17 AM
#18
gopinathgoswami avatar

gopinathgoswami

New Zenner

Join Date:
Nov 2011
Posts:
32
Plugin Contributions:
1

Re: Meta_tag_fbtitle - Facebook Addon

Hi,

You will have to uninstall your previous addon for FB and install the above referred addon fresh for it to work.

Regards
Gopinath Goswami

Gopinath Goswami
OnlineSurgicals.com

4 May 2012, 9:32 AM
#19
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

This is what I have in my html_header.php file and works fine.

<meta property="og:title" content="<?php echo META_TAG_TITLE; ?>" /> <meta property="og:type" content="product" /> <meta property="og:site_name" content="<?php echo STORE_NAME; ?>" /> <meta property="fb:admins" content="**enteryourfacebookadminnumberhere**" /> <?php if (isset($_GET['products_id'])) { // use products_image if products_id exists $facebook_image = $db->Execute("select p.products_image from " . TABLE_PRODUCTS . " p where products_id='" . (int)$_GET['products_id'] . "'"); $fb_image = HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . $facebook_image->fields['products_image']; } if ($fb_image == '') { // if no products image, use the default image if enabled $fb_image = '**insertdefaultimageurlhere.jpg**'; } if ($fb_image != '') { ?> <meta property="og:image" content="<?php echo $fb_image; ?>" />
4 Oct 2012, 3:49 PM
#20
serious avatar

serious

Totally Zenned

Join Date:
Feb 2011
Posts:
686
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

Time to revisit this....

Recently upgraded to zc1.50
Installed the Facebook like button add-on and got the dreaded FBIMG and FBtitle issue all over agin.

I deleted the "FB" as previously stated in the is thread from the includes/templates/CUSTOMTEMPLATE/common/html_header.php
Heres how it looks now:

<head> <title><?php echo META_TAG_TITLE; ?></title> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>" /> <meta name="keywords" content="<?php echo META_TAG_KEYWORDS; ?>" /> <meta name="description" content="<?php echo META_TAG_DESCRIPTION; ?>" /> <meta http-equiv="imagetoolbar" content="no" /> <meta name="author" content="The Zen Cart™ Team and others" /> <meta name="generator" content="shopping cart program by Zen Cart™, <http://www.zen-cart.com> eCommerce" /> <meta property="og:title" content="<?php echo **META_TAG_TITLE**; ?>"/> <meta property="og:site_name" content="<?php echo TITLE; ?>"/> <meta property="og:image" content="<?php echo **META_TAG_IMG**; ?>"/> <meta property="og:url" content="<?php echo $canonicalLink; ?>"/> <meta property="fb:admins" content="################"/> <meta property="og:type" content="product"/> <?php if (defined('ROBOTS_PAGES_TO_SKIP') && in_array($current_page_base,explode(",",constant('ROBOTS_PAGES_TO_SKIP'))) || $current_page_base=='down_for_maintenance' || $robotsNoIndex === true) { ?> <meta name="robots" content="noindex, nofollow" /> <?php } ?>

My problem currently is no images showing when I post a link to a product or category.
Also, posting a link to a category still shows META_TAG_FBTITLE on my FB page.

A sample link to a category if you want to try it yourself.
http://www.seriousoffroadproducts.com/Winches-Recovery-Gear/Winches/Smittybilt