Wednesday, February 1, 2012

web2py plugin_wiki tag

In my website, I want the user to be able to add tags to a picture. I'm happy because I can see that there is a plugin in web2py to do that.
Have look here: web2py Plugin but, it said that the plugin tag is kind of deprecated and we have to use the plugin_wiki.
Attention: some of the plugins listed here are old (in particular jqgrid, comments, tagging, modal, dropdow, attachments, latex, flash video and deprecated). Newer versions have been incorporated into plugin_wiki.
So I watched the video explaining how to use the plugin_wiki. But I don't want to create pages using the plugin_wiki, I just want to add tags!

Problem 
How to just add tags to my view file without using the wiki interface ?

Solution 
In fact it's really easy. In the view file just add this : {{=plugin_wiki.widget('tags',table='thumbnail',record_id=thumbnail.id)}}

thumbnail is the name of my table.
thumbnail.id is the id column (as you can guess)

Then, if you want to modify the behaviors you can modify the plugin_wiki controller : controllers/plugin_wiki.py, there is an action for each plugin, so you'll find an action called "tags".
And you can modify the "view" of a tag : view/plugin_wiki/tags.html

That's it !

No comments: