Facebook, Twitter and GooglePlus for Articles
Hi,
I would like to offer Facebook, Twitter and GooglePlus share buttons beneath articles (from the articles application) in the same way as they appear beneath discussions and comments.
However, after looking into the code of the respective social plugins as well as the vanilla core (on version 2.2b1), I would like to hear your opinion on how to proceed.
The problem is as follows (same as https://github.com/austins/Vanilla-App-Articles/issues/34):
Each of these social plugins declares a method on the PostController e.g. PostController_Facebook_Create($Sender, $RecordType, $ID)
that makes a call to a function GetRecord($RecordType, $ID)
which is defined in library/core/functions.general.php
.
The GetRecord()
function only supports "discussion", "activity" or "comment" for the RecordType argument, which are from the Vanilla app.
If I could just extend this function and add support for the "article" RecordType, everything would be fine, the social plugins would work without modification. However, I found out that functions from library/core/functions.general.php cannot be overwritten by plugins.
I really don't like adding code to the global bootstrap.*.php, also it is not recommended to overwrite functions from functions.general.php. Do I then really have to clone all the existing social plugins just to replace the GetRecord($RecordType, $ID)
call in one of their methods?
Any ideas would be appreciated!
Comments
http://vanillaforums.org/addon/articlessocialreactions-plugin
Is this what you are looking for?
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
@Bleistivt Thanks! However, I would like to offer exactly the same functionality, look & feel as the social react buttons beneath discussions. This plugin seems just to inject the standard facebook, twitter & co iframes to the articles (which is a bit critical due to the German data protection laws...). Therefore I would be very happy to reuse the functionality offered by the existing social plugins provided by Vanilla.
While it is technically true that you cannot override functions via the framework, most functions have include guards so you can define the functions before and take precedent.
Add your function definition to
/conf/bootstrap.before.php
to change it how you want. E.g.:Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight Thank you! That is what I will do for now. It would be nice to have the option to somehow extend the getRecord functionality in the future. In my opinion all those *Record functions in library/core/functions.general.php that deal with application specific data such as discussions from the Vanilla application do not really belong into the core library anyway...
Oh, and by the way, I really appreciate the quick and helpful responses I got on all my questions so far from all of you!
But even without using the bootstrap.before everride, you don't need to clone the existing social plugins. You could make a plugin just for the social react buttons and put the getRecord logic there as you probably need to create a new method on the ArticleController anyway.
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
If you are from Germany, chances are high you know the c't. A while ago, they showed their Shariff project and I thought that this could be a nice plugin for Vanilla.
I started to work at it in June but lost interest when it was mainly integrated. By now I think the plugin is fairly complete except for one problem: the height of div.Reactions in discussions is far to big. It looks okay in comments, though...
I published it on GitHub some minutes ago, just in case you like to use it.
I just uploaded the Articles Vanilla Social Reacions plugin: http://vanillaforums.org/addon/articlesvanillasocialreactions-plugin-0.1
It works by making use of the public interfaces of the Twitter, Facebook and Google+ plugins as well as their configuration.
@R_J: The shariff project is very interesting, but I was looking for a more unified look & feel to integrate with the rest of vanilla.
With my "Articles - Social Reactions" plugin that currently only adds social sharing buttons for articles, I decided to go with the bigger buttons because articles are more prominent per se than comments. For comments, I plan to make it look like same as how the social sharing icons show up under Vanilla comments. However, I don't want the plugin to be dependent on Vanilla being enabled. The social plugins bring up a dependency on the Vanilla application.
Your plugin looks awesome. I like how you made it work with the built-in Vanilla social plugins. Welcome to the community and thank you for trying out the Articles app and contributing to it, @mtschirs!
Add Pages to Vanilla with the Basic Pages app
That is why I called my plugin 'Articles Vanilla Social Reactions'
Actually, I think that the social plugins should / will technically work without Vanilla being installed. At least in the way I use them: as a basic social integration mechanism that can be extended to work with all kinds of content types and applications. It would be nice to strip out the Vanilla specific functionallity of the core and these plugins and put them in their own 'Vanilla' specific plugins.
Nevertheless, you are right, my intension was to match the 'look & feel' of the Vanilla application or rather the social reaction buttons provided by these social plugins for the Vanilla application. It also reduces the configuration complexity.
Also, in my current project, I consider articles and discussions equally important. However, it is just a matter of choosing the right CSS styling.
Anyway, I am very happy you put so much work into the articles application and share it with us. Thank you for your welcome