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 21 to 29 of 29
5 Oct 2012, 2:33 AM
#21
darkangel avatar

darkangel

Totally Zenned

Join Date:
Oct 2007
Location:
Emporia, Kansas
Posts:
1,729
Plugin Contributions:
0

Meta_tag_fbtitle - Facebook Addon

this is what mine looks like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" <?php echo HTML_PARAMS; ?> xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <title><?php echo META_TAG_TITLE; ?></title> <meta property="og:title" content="<?php echo META_TAG_FBTITLE; ?>"/> <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_FBIMG; ?>"/> <meta property="og:url" content="<?php echo $canonicalLink; ?>"/> <meta property="og:type" content="product"/> <meta property="fb:myinfo" content="my number"/> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>" /> <meta name="keywords" content="<?php echo CUSTOM_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" /> <?php if (defined('ROBOTS_PAGES_TO_SKIP') && in_array($current_page_base,explode(",",constant('ROBOTS_PAGES_TO_SKIP'))) || $current_page_base=='down_for_maintenance') { ?> <meta name="robots" content="noindex, nofollow" />

hopw that helps

10 Jan 2014, 4:32 AM
#22
dml73 avatar

dml73

Zen Follower

Join Date:
Oct 2007
Posts:
416
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

niccol:

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.

The og_tags.php file works for me, thanks for providing this. One question I have: how can I select the medium sized images instead of the regular sized images?
I assume that I need to modify this code:

if(substr($_GET['main_page'],-5) == '_info')
{
// this is a product info page
$sql = "SELECT p.products_image 
	FROM ".TABLE_PRODUCTS." p 
	WHERE p.products_id = '" . (int)$_GET['products_id'] . "'"
	;
$obj = $db->Execute($sql);
$og_image = HTTP_SERVER.DIR_WS_CATALOG.DIR_WS_IMAGES.$obj->fields['products_image'];
}

however Im not a programmer so Im not sure exactly how to change it.
10 Jan 2014, 2:57 PM
#23
niccol avatar

niccol

Totally Zenned

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

Re: Meta_tag_fbtitle - Facebook Addon

depends whether you are using image handler or not.

I haven't thought about this for ages to be honest. What is the problem with using the main image?

Nick
iszent.com

10 Jan 2014, 5:26 PM
#24
dml73 avatar

dml73

Zen Follower

Join Date:
Oct 2007
Posts:
416
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

niccol:

depends whether you are using image handler or not.

I haven't thought about this for ages to be honest. What is the problem with using the main image?

Im not using image handler. Im using the standard, MED and LRG image names.

The problem right now is that the images Facebook posts are the small images (those also used on the product listing page) so they get very blurred since Facebook are making them larger. So I want to have the code take my medium or even large sized images instead of small images.

10 Jan 2014, 5:38 PM
#25
niccol avatar

niccol

Totally Zenned

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

Re: Meta_tag_fbtitle - Facebook Addon

Well, if you send me an example of a large image name I will scribble some code for you. Or you can try this which is completely off the top of my head:

if(substr($_GET['main_page'],-5) == '_info')
{
// this is a product info page
$sql = "SELECT p.products_image
FROM ".TABLE_PRODUCTS." p
WHERE p.products_id = '" . (int)$_GET['products_id'] . "'"
;
$obj = $db->Execute($sql);
$large_image = str_replace('.','_LRG.',$obj->fields['products_image']);
$og_image = HTTP_SERVER.DIR_WS_CATALOG.DIR_WS_IMAGES.$large_image;
}

That is very rough and ready. It will break if your image names have a '.' in them. It will fail if there isn't a large image at all and won't fallback to the medium then the small. It won't work if you use a suffix other than 'LRG'.

Nick
iszent.com

10 Jan 2014, 5:45 PM
#26
dml73 avatar

dml73

Zen Follower

Join Date:
Oct 2007
Posts:
416
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

niccol:

Well, if you send me an example of a large image name I will scribble some code for you. Or you can try this which is completely off the top of my head:

if(substr($_GET['main_page'],-5) == '_info')
{
// this is a product info page
$sql = "SELECT p.products_image
FROM ".TABLE_PRODUCTS." p
WHERE p.products_id = '" . (int)$_GET['products_id'] . "'"
;
$obj = $db->Execute($sql);
$large_image = str_replace('.','_LRG.',$obj->fields['products_image']);
$og_image = HTTP_SERVER.DIR_WS_CATALOG.DIR_WS_IMAGES.$large_image;
}

That is very rough and ready. It will break if your image names have a '.' in them. It will fail if there isn't a large image at all and won't fallback to the medium then the small. It won't work if you use a suffix other than 'LRG'.

Ok thanks, a bit of fallback/failproof code would be great. My image names are for example: "usb-rs232-adapter-MED.jpg" for medium images and "usb-rs232-adapter-MED.jpg" for large images. (I changed the _MED to -MED).

11 Jan 2014, 5:54 AM
#27
dml73 avatar

dml73

Zen Follower

Join Date:
Oct 2007
Posts:
416
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

I just tried using the code you suggested above, unfortunately its not working, no image is being posted to Facebook. Could it be because I changed the name of the medium image from _MED to -MED? (I also changed the code to that, but still wont work)

11 Jan 2014, 9:42 PM
#28
niccol avatar

niccol

Totally Zenned

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

Re: Meta_tag_fbtitle - Facebook Addon

Shoot.

Yeah, I forgot to put the folder name in there too.

So something like:

if(substr($_GET['main_page'],-5) == '_info')
{
// this is a product info page
$sql = "SELECT p.products_image
FROM ".TABLE_PRODUCTS." p
WHERE p.products_id = '" . (int)$_GET['products_id'] . "'"
;
$obj = $db->Execute($sql);
$medium_image = str_replace('.','-MED.',$obj->fields['products_image']);
$og_image = HTTP_SERVER.DIR_WS_CATALOG.DIR_WS_IMAGES.'medium/'.$medium_image;
}

I'll have a think about fallback when I get a moment but it may not be for a few days.

Nick
iszent.com

13 Jan 2014, 3:59 AM
#29
dml73 avatar

dml73

Zen Follower

Join Date:
Oct 2007
Posts:
416
Plugin Contributions:
0

Re: Meta_tag_fbtitle - Facebook Addon

Thanks again but it still seems to be taking the small images because the images posted on Facebook are still blurred, like when a small image gets enlarged. Very strange.