Totally Zenned
- Join Date:
- Jan 2007
- Location:
- Los Angeles, California, United States
- Posts:
- 10,011
- Plugin Contributions:
- 3
Twitter Cards ( Summary Card with Large Image & Product)
So I'm messing around trying to set up the Twitter Card meta tags.. Need some help..
and before ANYONE suggests that Twitter Card module, don't.. The module it doesn't work and I've neither the time or the patience to mess with it to figure out why.. The instructions are vague, and seems like a lot of work when I can simply add the meta tags like I added the Facebook meta tags.. :smile:
Now that said.. here's what I've got thus far.. Using this page as a guide: http://codeboxr.com/blogs/twitter-card-and-how-to-use-product-card-to-promote-ecommerce
<?php
if (in_array($current_page_base, array('product_info', 'document_general_info', 'document_product_info', 'product_info_noproduct', 'product_music_info'))) {?>
<meta name="twitter:card" content="product">
<?php }else{?>
<meta name="twitter:card" content="summary_large_image" />
<?php }?>
<meta name="twitter:site" content="@YourTwitterAccount" />
<meta name="twitter:creator" content="@YourTwitterAccount" />
<meta name="twitter:title" content="<?php echo STORE_NAME; ?>" />
<?php
if (in_array($current_page_base, array('product_info', 'document_general_info', 'document_product_info', 'product_info_noproduct', 'product_music_info'))) {?>
<meta name="twitter:description" content="<?php echo strip_tags($products_description->info['products_description']); ?>" />
<?php }else{?>
<meta name="twitter:description" content="Your site description goes here." />
<?php }?>
<meta name="twitter:image" content="<?php echo HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_TEMPLATE . 'images/' . HEADER_LOGO_IMAGE; ?>">
The card type if statement is working just fine. On the product pages it returns the right meta tag on all other pages, the summary card meta tag is returned.. What I'm having trouble with is the description if statement.. I end up with the description tag on the product pages being empty as follows..
<meta name="twitter:card" content="product">
<meta name="twitter:site" content="@YourTwitterAccount" />
<meta name="twitter:creator" content="@YourTwitterAccountf" />
<meta name="twitter:title" content="Your Store Name" />
<meta name="twitter:description" content="" />
<meta name="twitter:image" content="http://www.yoursite.com/includes/templates/your-template/images/logo.jpg">
I took a GUESS on how to get the product description in.. So please do not giggle (out loud at least) at my failed attempt:laugh: I'm sure that what I did is WAAAAAAY off.. I need to add the same kind of if statement to the title so I grab the product name instead of the store name and the product image instead of the general image.. Finally I want to grab the price, model numbers, and maybe the manufacturer for good measure.. So if I can nail this one, I figure the others will be easy peezy.. (I hope..)
Could use a hand here in figuring this out.. Hoping the sharp minds in this forum can help..
Help???!!:laugh: