kiwi Posted July 7, 2021 Share Posted July 7, 2021 Could someone please help with this. I've added this open graph code between the head section of the main.php file and it works as it should. {if $PRODUCT} <meta property="og:title" content="{$META_TITLE}"> <meta property="og:image" content="{$PRODUCT.thumbnail}"> <meta property="og:url" content="{$VAL_SELF}"> {/if} But what I'm trying to work out is how to add the product description? <head> <title>{$META_TITLE}</title> {include file='templates/element.meta.php'} <link href="{$CANONICAL}" rel="canonical"> <link href="{$ROOT_PATH}favicon.ico" rel="shortcut icon" type="image/x-icon"> {include file='templates/element.css.php'} {include file='templates/content.recaptcha.head.php'} {include file='templates/element.google_analytics.php'} {include file='templates/element.js_head.php'} {if $PRODUCT} <meta property="og:title" content="{$META_TITLE}"> <meta property="og:image" content="{$PRODUCT.thumbnail}"> <meta property="og:url" content="{$VAL_SELF}"> {/if} </head> Link to comment Share on other sites More sharing options...
bsmither Posted July 7, 2021 Share Posted July 7, 2021 The complete description? Or maybe you can use the short description? The template variable {$PRODUCT.description} or {$PRODUCT.description_short} could be used. Better might be: {$PRODUCT.description_short|escape|strip_tags:false} Link to comment Share on other sites More sharing options...
kiwi Posted July 8, 2021 Author Share Posted July 8, 2021 Thanks for the help I tried these variable {$PRODUCT.description} and {$PRODUCT.description_short} and they didn't work but this one did {$PRODUCT.description_short|escape|strip_tags:false} <meta property="og:description" content="{$PRODUCT.description_short|escape|strip_tags:false}"> But it shows the p tags, I tried this, strip_tags:true with no luck "{$PRODUCT.description_short|escape|strip_tags:true}" any ideas? Thanks for your help it's appreciated. Link to comment Share on other sites More sharing options...
bsmither Posted July 8, 2021 Share Posted July 8, 2021 I am thinking that the 'escape' is converting certain characters to their HTML entity (< to <), which means strip_tags no longer sees them. So try reversing the order: {$PRODUCT.description_short|strip_tags:false|escape} But I fear that attempting to strip the tags first may inadvertently catch angle brackets that are not tags. So beware. Link to comment Share on other sites More sharing options...
kiwi Posted July 8, 2021 Author Share Posted July 8, 2021 That work a treat, Thanks for the help, much appreciated. For those interested this is what's in my main.php <head> <head> <title>{$META_TITLE}</title> {include file='templates/element.meta.php'} <link href="{$CANONICAL}" rel="canonical"> <link href="{$ROOT_PATH}favicon.ico" rel="shortcut icon" type="image/x-icon"> {include file='templates/element.css.php'} {include file='templates/content.recaptcha.head.php'} {include file='templates/element.google_analytics.php'} {include file='templates/element.js_head.php'} {if $PRODUCT} <meta property="og:title" content="{$META_TITLE}"> <meta property="og:description" content="{$PRODUCT.description_short|strip_tags:false|escape}"> <meta property="og:image" content="{$PRODUCT.thumbnail}"> <meta property="og:url" content="{$VAL_SELF}"> {/if} </head> And this is the FaceBook open graph tool for checking https://developers.facebook.com/tools/debug/ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.