Keyword

Twitter card & Facebook Open Graph to K2 articles

  • Robert
  • Robert's Avatar Topic Author
  • Offline
  • New Member
More
6 years 1 month ago #166804 by Robert
Hello, we have a website with Joomla whose template is used RocketTheme Hadron and we use K2 to publish our articles. We have a problem when we share our articles on Facebook and Twitter, the image of the article concerned, its title and description do not go back. We searched for Twitter Cards and Facebook (Open Graph) but we are new to the subject. Can someone help us please? Thank you very much.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 1 month ago #166857 by Krikor Boghossian
Replied by Krikor Boghossian on topic Twitter card & Facebook Open Graph to K2 articles
Hello,

Can you send me a link to the site?

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

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

More
6 years 4 weeks ago - 6 years 4 weeks ago #166874 by STEPHAN HERBY
Replied by STEPHAN HERBY on topic Twitter card & Facebook Open Graph to K2 articles
Hi Robert,
I have met this issue with Twitter Card. I had to hack one file in K2 to have Facebook AND Twitter Card propely display. Krikor will probably say (and with reason :) DO NEVER HACK A CORE FILE.

But I didn't find another solution. SO this is How I did the trick :

K2 - Parameters
  • Go to K2 component
  • Go to tab "Social"
  • Make sure "Enable Facebook meta tags" is on "Yes" and choose your Image size for "og:image" (I choose Medium for example).
Hack file
  • Find file : component -> com-k2 -> models -> item.php
  • Open it with a text editor (Coda for me i.e.)
  • Find line 565 :
    // Set Facebook meta data
  • After lines 593 :
    $document->setMetaData('og:description', strip_tags($document->getDescription()));
    Add lines :
  • // Hack - Set Twitter meta data if FB = 1
    			$document->setMetaData('twitter:card', 'summary_large_image');
    			$document->setMetaData('twitter:site', '@yourtwitteraccount');
    			$document->setMetaData('twitter:creator', '@yourtwitteraccount');
    			$document->setMetaData('twitter:url', $uri->toString());
    			$document->setMetaData('twitter:title', (K2_JVERSION == '15') ? htmlspecialchars($document->getTitle(), ENT_QUOTES, 'UTF-8') : $document->getTitle());
    			$document->setMetaData('twitter:description', strip_tags($document->getDescription()));
    			$document->setMetaData('twitter:image', $image);
    		}
  • Et voilà ! Twitter Card are now display in your header in each K2 item
Hope this help .
Don't forget to replace "@yourtwitteraccount" by your Twitter account of course.
Don't forget to make a backup of the file concerned BEFORE making your hack, in case you do something wrong.
Last edit: 6 years 4 weeks ago by STEPHAN HERBY.

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

  • Robert
  • Robert's Avatar Topic Author
  • Offline
  • New Member
More
6 years 4 weeks ago #166877 by Robert
Thank you very much, it works now on Twitter but on Facebook the title and description are those of the site, not the article. Do you have a solution, please? Many thanks !

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

More
6 years 4 weeks ago #166888 by STEPHAN HERBY
Replied by STEPHAN HERBY on topic Twitter card & Facebook Open Graph to K2 articles
Hi Robert,
Do you have any link ? Maybe there's another plugin activated like CoalaSocialLink ?

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

  • Robert
  • Robert's Avatar Topic Author
  • Offline
  • New Member
More
6 years 4 weeks ago #166899 by Robert
Yes of course, here is a link to an article:
This message contains confidential information


  When I test the link from developers.facebook.com/tools/debug/
it is the title of the site and the description of the site which appear in the fields og: title and og: description

The code that handles these items is just above the code you added to me earlier. Surely there is a way to change that in the file?

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

More
6 years 4 weeks ago #166900 by STEPHAN HERBY
Replied by STEPHAN HERBY on topic Twitter card & Facebook Open Graph to K2 articles
Mmmh..; I can just see "This message contains confidential information" in your answer where you try to give me an URL...
Anyway... I didn't change anything for Facebook Meta, I just added the Meta for Twitter Card and everythings work well for me on all my K2 items. This is why i asked you if there's any 3rd party extension installed to manage Meta ?
I have already noticed that sometimes default META insert in Joomla configuration are used instead of K2 items. maybe could you try to empty Joomla general META in configuration and see if then K2 item Meta are display ?
If then, let Joomla configuration general META empty, so k2 items META will be used instead. And place some META manually on all menu links where it is needed ? That's what I usually do...

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

  • Robert
  • Robert's Avatar Topic Author
  • Offline
  • New Member
More
6 years 4 weeks ago #166901 by Robert
Yes of course, here is a link to an article:

www.cabcl-association.com/site/medias/toute-l-actualite/item/851-club-demba-bamba-avec-france-u20-pour-preparer-un-crunch-decisif


When I test the link from developers.facebook.com/tools/debug/
it is the title of the site and the description of the site which appear in the fields og: title and og: description

The code that handles these items is just above the code you added to me earlier. Surely there is a way to change that in the file?

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

More
6 years 3 weeks ago #166904 by STEPHAN HERBY
Replied by STEPHAN HERBY on topic Twitter card & Facebook Open Graph to K2 articles
OK I can see the link now... great! :)
So when I have a look at the code, I can see that META OpenGraph from K2 are there and with the good content (Title, description, etc...).
<meta property="og:url" content="https://www.cabcl-association.com/site/medias/toute-l-actualite/item/851-club-demba-bamba-avec-france-u20-pour-preparer-un-crunch-decisif">
	<meta property="og:title" content="CA Brive Rugby #Formation - CLUB : Demba BAMBA avec France U20 pour préparer un Crunch décisif.">
	<meta property="og:type" content="article">
	<meta property="og:image" content="https://www.cabcl-association.com/site/media/k2/items/cache/6ffa065634b02c07506d37e072a9ff8b_M.jpg">
	<meta name="image" content="https://www.cabcl-association.com/site/media/k2/items/cache/6ffa065634b02c07506d37e072a9ff8b_M.jpg">
	<meta property="og:description" content="L’encadrement tricolore a retenu 32 joueurs pour préparer un Crunch décisif. La préparation du match de l’Angleterre se fera en deux moments distincts...">

But there's a second Meta OpenGraph at the end of the header with the Title and description of the website. As it is the last one, Facebook take that one for filling his fields...
<meta property="og:url" content="https://www.cabcl-association.com/site/">
<meta property="og:image" content="https://www.cabcl-association.com/site/templates/rt_hadron/images/logo/logo-og.png">
<meta property="og:title" content="CA Brive Rugby #Formation">
<meta property="og:description" content="Site officiel de la formation du CA Brive Rugby.
Toute l'actualité et les résultats des jeunes du CABCL.">
This could come from a 3rd party component or plugin. Or maybe just the META info from main menu ? Have a look... Even on your homepage this 2nd META are displayed. And there's #formation in the title that should not be here neither... Did you check your Joomla configuration META description ? Check also this probably 3rd party component or plugin... And come back with this info here... Coala Social Link did the same on my websites and i had to de-activate all META parameters from this component to have back my good K2 META.

PS : J'aime le rugby et j'aurais pu continuer en français, mais bon :)

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

  • Robert
  • Robert's Avatar Topic Author
  • Offline
  • New Member
More
6 years 3 weeks ago #166924 by Robert
Bonjour Stephan et merci pour toutes vos réponses. Si j'avais su effectivement j'aurais posté en français, mais j'ai préféré aller sur le forum anglais ou il y à potentiellement plus de monde.

J'ai toujours le problème avec l'open graph Facebook au niveau du titre des articles. C'est le titre du site qui est récupéré et non celui de l'article. J'ai pu résoudre le problème de la description en supprimant la description du site et en l'insérant dans le lien du menu de la page d'accueil. Nous n'utilisons pas de module supplémentaire pour gérer les méta.

Merci.

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


Powered by Kunena Forum