Keyword

og-metatag not rendered correctly

  • Steven Trooster
  • Steven Trooster's Avatar Topic Author
  • Offline
  • Premium Member
More
6 years 2 months ago #169027 by Steven Trooster
og-metatag not rendered correctly was created by Steven Trooster
I've added meta tags to a template override to have OG-metatags for Facebook and Twitter in the rendered page of an (K2) article. For safety reasons it is advised to escape the title tag. So my code is:
$document->addCustomTag('<meta property="og:title" content="'.$this->escape($this->item->title).'">');

This will create a tag that looks like this, where the title of the page is Ugenda's festivaloverzicht :
<meta property="og:title" content="Ugenda&amp;#039;s festivaloverzicht">

See an example here: www.ugenda.nl/agenda/festivals

Note that the title has the wrong encoding for the apostrophe. It should be &#039; or &apos;.
So Facebook doesn't recognize the titel correctly and it shows the encoding instead of the apostrophe. (See: www.facebook.com/Ugenda/posts/10156534292767719 )

Am I escaping the item->title falsely? Or is there no need to escape it? (And what about security?)

Note that in pages in the eventlist part of our site, the og-tag is rendered correctly. See for example: www.ugenda.nl/agenda/event/102529-battlefield-fietstour-de-bevrijding-van-nijmegen where the tag is:
<meta property="og:title" content="Battlefield Fietstour 'De bevrijding van Nijmegen'">
and the code:
$document->addCustomTag('<meta property="og:title" content="'.$this->escape($this->item->title).'">');

Please Log in or Create an account to join the conversation.

More
6 years 2 months ago #169037 by JoomlaWorks
Replied by JoomlaWorks on topic og-metatag not rendered correctly
K2 properly adds opengraph tags for Facebook and Twitter. You don't need to do that. If you did not see the meta tags in your source, perhaps some other (system) plugin is stripping them up.

See the source code here for example: demo.getk2.org/item

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum