开发者

modify drupal views output to diplay a facebook like button

How can I edit views output rows to include a facebook like button and that like statement should take one of t开发者_Python百科he field as parameter and output on facebook as ::

abc user likes "content of field" on mywebsite.com


I think its possible in views.

Goto http://developers.facebook.com/docs/reference/plugins/like and you will see how to generate arbitrary code for a facebook like button.

Basically it looks like this

<iframe src="http://www.facebook.com/plugins/like.php?href=YOUR_URL_HERE&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

Notice YOUR_URL_HERE, you need to replace that dynamically in views. First you should output some field lets call it Some_Field. It contains the thing you want to "like" in Facebook. It should be a URL because facebook like works on URLs. Next, you should add a Custom Text field (under the Global Group). In the text section you can use the replacement pattern [Some_Field]. So your the text section would be like this:

<iframe src="http://www.facebook.com/plugins/like.php href=[Some_Field]&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

Note that the Custom Text Field should come after Some_Field, otherwise Some_Field will not be available as a replacement pattern.


If you go to your view and click on theme information link, it's one of the last items in the left column, you get a list of templates that views can/will use.

Overwrite one of these templates and do your custom styling there. That is usually the easiest option with views. This is normal Drupal theming, the new template with the correct name should be in your theme along with your other template files.

You can also overwrite the theme function for your field, but that is usually a bit more complicated to do.


I found a more appropriate solution. Using the views custom field module, you can add the iframe code that facebook provides and use token values to enter in the URL of the code. Basically you can configure the output using tokens generated by previous added fields.

Also the flag module can be of help to add only certain flags e.g. Report this link as broken. Actions can be associated with flags, like increment a counter etc.

Hope this helps !!


Use fb_social module to implement this functionality. It is extremely easy and straight forward way to add like-box, like-buttons and all other facebook's social plugins to Drupal without too much hassle.


The flag module will make this functionality very easy for you to implement. It's very easy to work with and you will quickly be able to set this up.


You can add the fb social like button as a field in views. It is available after installing the fb social module.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜