views:

225

answers:

5

How can I edit views output rows to include a facebook like button and that like statement should take one of the field as parameter and output on facebook as ::

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

+2  A: 

If you go to your theme 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.

googletorp
I only want to modify the output of the views basically, not a complete theme makeover. Can you point me towards right resources where I can learn how to do so.
Nikhil
You wouldn't be doing a theme makeover - the view template files simply allow you to override the view output. The theme information link will give you template code you can paste into a .tpl.php file and add it to your theme folder. Modify it as you need and them upload.
Jared
A: 

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.

mirzu
can it be used to implement facebook like feature
Nikhil
+2  A: 

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;amp;layout=standard&amp;amp;show_faces=true&amp;amp;width=450&amp;amp;action=like&amp;amp;colorscheme=light&amp;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.

Sid NoParrots
I'll let you know how it worked out to be.
Nikhil
A: 

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 !!

Nikhil
A: 

funny that iframe was removed. I tried to use tag but removed too on field rewrite.

anyone have luck on this?

edit:

it turns out that view customfield module really help. :)

benzwu
Is your problem solved now ?
Nikhil

related questions