The catalyst for the extension was CSS star rating from Komodo Media and the extension contains CSS and images from this project.
To add some web 2.0 goodness, if the xajax extension is enabled and the user has access ratings will be done via ajax calls. The xajax component requires newer versions (0.5+) of the xajax library so it must be downloaded from the projects site an not from the contributions section of the eZ site.
View caching & dynamic contentOne of the issues I came across is that by making the rating a datatype, is that the display gets "captured" in the view cache. This is not not good for a dynamic component. To prevent caching I tried setting the cache_ttl to zero in the datatype view, however this has no effect. It appears that this template setting only works when used in a view template...something to investigate.
An earlier strategy was to clear the view cache after each "vote" and while this works to some extent it fails with anonymous users. View caches are based on the user viewing the node, and because all non logged in users share the special anonymous user they also share the view caches. Once one anonymous user voted the page would be updated with the results and the voting disabled, however the next anonymous user to visit the page would see the cached page containing the result and be unable to vote.
A worthy addition to the eZ template system would be the ability to designate a block in any template as being dynamic and not cached.
The TODO listCurrently the TODO list stands at
- Fetch most rated objects;
- Set max rating in datatype (class or content?);
- Ability to clear ratings from datatype;
- Stats - An admin view of voting that displays an over view of the rated content. Allow filtering/ sorting by content type;
- Options for vote uniqueness - currently per session only. This covers both Anonymous & logged in users. Could make it based on user_id or session so that logged in users can only vote once;
- Ability to limit voting to logged in user;
- Log IP addresses and add this in the mix of unique voting.
If you find the extension useful, have any comments, or suggestions let me know via comments. Also if you use it in a public site drop me a line. Also nice to seeing ones creations in the wild!