Elxis CMS Forum
Support => Elxis 4.x/5.x DEV => Topic started by: seadhna on February 26, 2014, 11:20:17
-
Hi there,
wondering if it is possible to add open graph meta tags to individual articles (e.g. to control which image is shared on Facebook when the page is shared). Wordpress has a plugin for this I think but can't find anything in the Download Centre.
-
It is very easy to add meta data in Elxis 4.x but to do this from the editor you need a plugin.
What kind of meta data you want to add. Can you write some HTML examples?
Adding custom meta tags in Elxis 4.x
eFactory::getDocument()->setMetaTag($name, $content);
-
I suppose that the right place of Open Graph protocol is described here: http://ogp.me/
-
I would like to add this line to many articles on the site:
<meta property="og:{tagName}" content="{tagValue}"/>
but the tagName and tagValue must be different on each article. Is this possible?
-
You need a special plugin to do this.
-
Thanks, what is the plugin?
-
A plugin is an Elxis extension type which processes articles and performs various tasks.
For instance a plugin like the one I tell you could grab article's title and add the og:title meta tag in page headers automatically.
-
If you install facebook like plugin (https://www.elxis.net/edc/social/5.html) it will add for you some og metatags at the articles where you add the plugin
for example from my site
<meta property="og:type" content="article"/>
<meta property="og:url" content="http://www.site.com/article.html"/>
<meta property="og:site_name" content="example"/>
<meta property="og:locale" content="el_GR"/>
<meta property="og:title" content="artcle title"/>
<meta property="og:image" content="article image"/>
If this suits your needs then you can try it.
-
Ah, interesting, I have already built that!
There are so many the extensions I have built that I dont remember them all ;D
-
There is an option at the content plugin parameters, thanks to Datahell. ;D The same option exist not only at facebook like content plugin but also at facebook comments content plugin.
So if you install one of these two and enable the option it will add for you these og metatags (together with like button or comments box) at the articles where you add them.
(http://i58.tinypic.com/30jkwo3.png)
-
Hi again, thanks - this is great to learn about these plugins. I have the 'facebook like' plugin working but cannot get the 'facebook comment' plugin working. I get the error on the front-end (in Chrome):
href URL is not properly formatted
Doctype is HTML5:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />...etc...
However, in the source, the URL is using special characters which I think is causing the problem - any ideas why?:
http%3A%2F%2Fwww...etc...
-
I face in the past the same issue.
I realize that this i caused by urlencode($curl). Urlencode (http://www.php.net/urlencode) adds this % symbols at url replacing some characters and as a result facebook comments don't work.
What i did: i open the plugin, components/com_content/plugins/fcomments/fcomments.plugin.php
and at line 106 i replace .urlencode($curl). with .$curl.
and since then it works without any problem
Maybe this is not the appropriate way to solve this, as it says in the manual Urlencode is a convenient way to pass variables to the next page.
But in real life everyone who try to pass a url parameter to facebook comments using this, face the same issue so we must do something. This is not just for elxis!
Also i would like to note that although Urlencode is used and at "facebook like content plugin" it does not produce any error there. The problem is only at facebook comments mainly because facebook comments don't "understand" urls with %.
I think it is save to omit urlencode because as i can see at og its not used: <meta property="og:url" content="'.$curl.'"/>
But wait for datahell opinion.
-
Facebook has the worst integration code ever. I don't use it, I don't recommend it, and I don't like it.
URL encode is the proper method to pass strings into URLs, especially if they contain non latin characters.
If this modification worked for you, I have nothing to say except to warn you that it might not work for people from other countries. It is a subject of the integration method.
-
Thanks for this michalis1984, this worked for me too. I agree with all your points datahell - it's an English language only site and must have FB integration though - making it responsive is another challenge...