Facebook-Button RealBlog

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

smik
Posts: 25
Joined: Tue Nov 25, 2008 4:02 pm

Facebook-Button RealBlog

Post by smik » Wed Feb 18, 2015 10:19 am

Hi Guys,

I use the RealBlog Plugin by Gert. Now I wonder if there is a way to have a Facebook-like and share-button for each blog-post individually.
It would be nice if the button is set automatically below each post, so that people can like and share the post on facebook.

Facebook offers a way to generate the buttons manually like here:

https://developers.facebook.com/docs/pl ... cale=de_DE

But for this I had to:
1. generate my post
2. publish it
3. copy the URL of my post
4. go to the above FB-site
5. insert the URL
6. generate the code
7. go back to my post and insert the code into the HTML section

... you see that's a whole lot of steps... which is unconfortable and annoying

Is there a way to have those buttons generated automatically below each post, for exaple using a placeholder of CMSimple for the URL of the post?

Hope someone knows a way.

Thanks in advance!
Robert

cmb
Posts: 13273
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Facebook-Button RealBlog

Post by cmb » Wed Feb 18, 2015 12:34 pm

smik wrote:Is there a way to have those buttons generated automatically below each post, for exaple using a placeholder of CMSimple for the URL of the post?
Well, there are several plugins which embed Facebook Like buttons: Facebook_XH, Socialshareprivacy_XH, Faceblink and SocialWebButtons (note that there are restrictions on the CMSimple variant/version they're compatible with). Off the top of my head I can't say whether all of them allow/use individual URLs for the like, but at least Socialshareprivacy_XH does. You can see that on my website; just click once on the Facebook Recommend button and you can see the number of likes -- it's different on different pages.

The harder part is to generate the buttons automatically below each post. The simplest solution would be to call the plugin from the template, but this way the buttons will be shown always (non blog related pages, blog overview etc.) If that's okay, fine. Otherwise you would have to guard the plugin call depending on parts of the URL, maybe the following way:

Code: Select all

<?php if (isset($_GET['realblogaction']) && $_GET['realblogaction'] == 'view'):?>
  <!-- plugin call -->
<?php endif?>
Another option would be to add the respective plugin call to each article manually.
Christoph M. Becker – Plugins for CMSimple_XH

smik
Posts: 25
Joined: Tue Nov 25, 2008 4:02 pm

Re: Facebook-Button RealBlog

Post by smik » Wed Feb 18, 2015 1:22 pm

Hi Christoph,

thanks for the quick reply. I already tried SocialWebButtons but it isn't linked to the URL... you can just generally like the website as a whole. The thing I need is, that each post should be liked individually.
I didn't try Socialshareprivacy yet... it seems to do what I want it to, but it misses the share button :( could it be added?

This is how I made it manually work in the before mentioned way... it's unconfortable but that's how it should work...

http://www.petragraak.de/?Blog&T%C3%BCr ... D=1&page=1

Is there no way to get the URL of the site (for example via some kind of CMSimple-Placeholder) automatically?

Code: Select all

<iframe src="//www.facebook.com/plugins/like.php?href=[b][color=#FF0000][b]URL-OF-THE-WEBSITE-GENERATED-AUTOMATICALLY[/b][/color][/b]&width&layout=button&action=like&show_faces=false&share=true&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:35px;" allowTransparency="true"></iframe>
This way I could set the code in a dedicated template for the Blog-Page and it would fill in the URL automatically... that would be great!

Best regards
Robert

Gert
Posts: 3054
Joined: Fri May 30, 2008 4:53 pm
Location: Berlin
Contact:

Re: Facebook-Button RealBlog

Post by Gert » Wed Feb 18, 2015 1:35 pm

smik wrote:I already tried SocialWebButtons but it isn't linked to the URL... you can just generally like the website as a whole.
That's not true.

On my Demo Page I have one demo here:

http://www.ge-webdesign.de/plugindemo/? ... it_Counter

and another demo here (at the bottom of the page):

http://www.ge-webdesign.de/plugindemo/? ... erklaerung

You can see the different numbers, the plugin call is the same on both places.

Theoretically you can call the plugin in the template, and will have different counts on every page. But I don't know, if it works for RealBlog entries, because all entries are on the same CMSimple page, only the Query String is different. But you could test it for me ;)

Code: Select all

<?php echo swb_content('visible'); ?>
Gert
Gert Ebersbach | CMSimple | Templates - Plugins - Services

cmb
Posts: 13273
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Facebook-Button RealBlog

Post by cmb » Wed Feb 18, 2015 1:55 pm

smik wrote:I didn't try Socialshareprivacy yet... it seems to do what I want it to, but it misses the share button :( could it be added?
Most likely not. On one hand I have to switch to Shariff, which is an improved successor of Socialshareprivacy, in the near future, and on the other hand there is already Facebook_XH, which offers like and share buttons. It's possible to combine it with the solution given below.
smik wrote:Is there no way to get the URL of the site (for example via some kind of CMSimple-Placeholder) automatically?
To access the currently selected page, you could use the variable $su. But that won't work for Realblog, as all articles are on the same CMSimple page. You can, however, assemble the URL from its components, what seems to be the cleanest solution:

Code: Select all

<?php echo CMSIMPLE_URL . '?' . $su . '&realblogaction=view&realblogID=' . $_GET['realblogID']?>
(untested, works for CMSimple_XH only due to CMSIMPLE_URL; you could hard-code the base URL instead)

Another option would be to use $_SERVER['REQUEST_URI'], if it's available (no problem for Apache servers, at least). Basically the same is done by Socialshareprivacy (but in this case on the client side). Both latter approaches have the drawback, that the URL might be different (additional unnecessary parameters, swapping of parameters), and that might confuse Facebook.
Gert wrote:Theoretically you can call the plugin in the template, and will have different counts on every page. But I don't know, if it works for RealBlog entries, because all entries are on the same CMSimple page, only the Query String is different.
Unless there's some URL rewriting in place, the URLs to individual CMSimple pages differ only in the query string, anyway.

PS: I've just seen that you are using CMSimple 4.5 on the site. In this case the warning against _XH plugins applies.
Christoph M. Becker – Plugins for CMSimple_XH

smik
Posts: 25
Joined: Tue Nov 25, 2008 4:02 pm

Re: Facebook-Button RealBlog

Post by smik » Wed Feb 18, 2015 1:57 pm

Hi Gert,

just tried ist, but I get an error, when I call the Plugin from the template, although I set it to "true" in the config:
Das Plugin SocialWebButtons kann an dieser Stelle nicht aufgerufen werden, da es für den Aufruf im Template konfiguriert ist. Bitte ändern Sie die Plugin Konfiguration.
Before I tried to call it from the content and that worked just fine... apart of the missing Share-Button and the fact, that it only got the global website istead of the individual Blog-Post... I called the plugin from the post directly by entering {{{PLUGIN:swb_content('visible');}}} right below the blog-text

I just tried it again... here you see the effect :-)

http://www.petragraak.de/?Blog&T%C3%BCr ... D=1&page=1

Now I got both scripts in... your plugin and the manually generated links.

Your plugin doesn't seem to get the URL for the blog... unfortunatelly

Best regards
Robert

smik
Posts: 25
Joined: Tue Nov 25, 2008 4:02 pm

Re: Facebook-Button RealBlog

Post by smik » Wed Feb 18, 2015 2:04 pm

Hi Christoph,

thanks for your engagement...

Unfortunately I didn't use CMSimple_XH BECAUSE auf the Blog... it worked better with CMSimple 4.5 > normally I use _XH...

So there seems to be no solution for the blog? :cry:

Thanks anyways for your kind support!
Robert

cmb
Posts: 13273
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Facebook-Button RealBlog

Post by cmb » Wed Feb 18, 2015 2:57 pm

smik wrote:Your plugin doesn't seem to get the URL for the blog... unfortunatelly
Well, the plugin gets the URL and sets the href parameter of the Facebook Like request appropriately. Maybe there is an issue on the Facebook side.
smik wrote:Unfortunately I didn't use CMSimple_XH BECAUSE auf the Blog... it worked better with CMSimple 4.5 > normally I use _XH...
Using Realblog_XH shouldn't be a problem, besides that Twocents_XH is still very meager, and there's no alternative available yet. :(
smik wrote:So there seems to be no solution for the blog? :(
Please try the following in the template:

Code: Select all

<iframe src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode('http://www.petragraak.de/?Blog&realblogaction=view&realblogID=' . $_GET['realblogID'])?>&width&layout=button&action=like&show_faces=false&share=true&height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:35px;" allowTransparency="true"></iframe>
Christoph M. Becker – Plugins for CMSimple_XH

smik
Posts: 25
Joined: Tue Nov 25, 2008 4:02 pm

Re: Facebook-Button RealBlog

Post by smik » Wed Feb 18, 2015 4:01 pm

if I put it in the template it results in a blank white site and if I put it in the content nothing appears in the frontend... unfortunately

see here: http://www.petragraak.de/?Blog&Testpost ... D=2&page=1

cmb
Posts: 13273
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Facebook-Button RealBlog

Post by cmb » Wed Feb 18, 2015 4:34 pm

smik wrote:if I put it in the template it results in a blank white site
Syntax error :oops: Fixed now.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply