Saturday 10 October 2009 11:43:18 pm
Hello Stephane, I haven't used the ezstarrating extension you mentioned so far, so cannot confirm its being useful here, but I don't expect it to be fit for your needs out of the box. As the matter of fact, I think it has a slightly different purpose. If I understood correctly, you want to have a rating-review pairs for hotel objects and then aggregate the ratings from all those pairs. My solution would be a dedicated one, and quite easy (even though it may seem complicated). I would simply create a simple review content class that would consist of at least the review textblock and rating selection (1-10 for example), but for the latter I would necessarily use a datatype that stores the selected number directly in data_int field of ezcontentobject_attribute table. I'm not sure if any built-in datatype does just that, so there might be a need for a very simple dedicated one. Having that, I would write a simple template operator that would actually wrap around an SQL query that would fetch and aggregate the ratings directly from the database. The SQL would like something like: SELECT COUNT(coa.data_int) AS vote_count, SUM(coa.data_int) AS vote_sum
FROM ezcontentobject_attribute coa, ezcontentobject_tree cot, ezcontentobject co
WHERE co.id=cot.contentobject_id
AND co.id=coa.contentobject_id
AND co.status=1
AND cot.path_string LIKE '{$NODEPATH}%'
AND coa.contentclassattribute_id={$CCAID}
AND co.current_version=coa.version
...
where $NODEPATH would be a path of current hotel node for which reviews are aggregated, and $CCAID would be the ID of content class attribute that stores the actual rating. This solution would be able to handle many more reviews than template based one and would avoid struggling with rating system adaptation. I hope this may be useful for you.
Cheers, Piotrek PS. The above SQL is just out of my head, it may have some problems to it, but that's definitely doable.
--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu
|