How should I build a view (query) into a content type?

cmundi - May 31, 2009 - 18:43

Hi.

I think I'm making something too hard. I need help to get on the right path.

Views are great (obviously) but it seems that the real power of Drupal will come from folding those views into other content types.

Let me give a specific example. I am adding product reviews to my site.

Each product needs and Expert Rating and an Average User Rating.

I already have the Editor Rating implemented. It's just a FiveStar field that an authorized editor sets.
But the Average User Rating is more complex. It has to be computed on the fly from the data managed by the Voting API.
What I need is a way to embed data in my Product content type (created with CCK) that pulls data from the Voting API on the fly.

I tried using ViewField but am not having much luck. The docs for ViewField are sparse (not complaining, just stating fact) so I'm wondering if this is even the right approach.

I am using CCK to provide a Review content type.
I am using FiveStar to provide static Expert Rating and Voting API to collect user ratings in comments.
I am using Views to provide search capability based on criteria including user ratings.

Thanks!

Humm I'm not sure I

patchak - May 31, 2009 - 19:10

Humm I'm not sure I understand your question... If you enable the fivestar widget and the fivestar comments feature, then the calculation for the widget will happen automatically according to the values given by your users in the comments for a node.

This is not the same thing as a fivestar field, that is editable by the editor, so effectively you would have two set of stars!!

Try to setup the fivestar comments feature in the edit page of the content type you want the users to rate by commenting the node!

Hope this helps,
Patchak

Thanks - I'll try that

cmundi - May 31, 2009 - 19:13

@patchak: I will try that. It sounds like I have not fully explored what fivestar can do on its own.

Hm. I may have a bigger problem.

cmundi - May 31, 2009 - 20:44

I have configured fivestar globally to use the default star style.
I have a content type called Product Review, for which I have checked "Enable Fivestar rating."
Now I create a piece of content of type Product Review. I see no direct rating!

So I enabled fivestar for comments (within the Product Review content type).
Now comments get ratings, but the Product Review node itself has no ratings.

Possibly relevant observation: The " Direct rating widget preview" graphic (admin/content/node-type/review) is static for me. If I change the options -- like disabling and then reenabling fivestar on the same page, the preview graphic flashes on and then off very quickly. It does not stay on! I wonder if this is happing in the normal view. That would explain why I get no fivestar rating.

Is this a known issue?

Thanks!

Additional information:

This is a test site hosted on Ubuntu Jaunty Jackelope:

Access to update.php Protected
Configuration file Protected
Cron maintenance tasks Last run 20 min 55 sec ago
You can run cron manually.
Database updates Up to date
Drupal core update status Up to date
File system Writable (public download method)
GD library 2.0 or higher
Module and theme update status Up to date
MySQL database 5.0.75
PHP 5.2.6-3ubuntu4.1
PHP memory limit 64M
PHP register globals Disabled
Unicode library PHP Mbstring Extension
Update notifications Enabled
Web server Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch mod_ssl/2.2.11 OpenSSL/0.9.8g

All of my modules are up to date:

Drupal core
Up to dateok
Drupal 6.12
Includes: Block, Color, Comment, Database logging, Filter, Garland, Help, Menu, Node, Search, System, Taxonomy, Update status, User
Modules
Up to dateok
Advanced help 6.x-1.2
Includes: Advanced help
Up to dateok
Amazon 6.x-1.0-beta5
Includes: Amazon API, Amazon field
Up to dateok
Content Construction Kit (CCK) 6.x-2.2
Includes: Content, Fieldgroup, Text
Up to dateok
Fivestar 6.x-1.15
Also available: 6.x-2.x-dev (2009-May-11)

* Download
* Release notes

Includes: Fivestar, Fivestar Comments
Up to dateok
Viewfield 6.x-1.x-dev (2009-May-24)
Includes: Viewfield
Up to dateok
Views 6.x-2.5
Also available: 6.x-3.x-dev (2009-May-20)

* Download
* Release notes

Includes: Views, Views UI
Up to dateok
Voting API 6.x-2.0-rc2
Includes: Voting API

Does not depend on browser

cmundi - May 31, 2009 - 20:47

I forgot to mention. Firefox 3.0.10 and IE7 both show the same behavior.

I'm going to start over from scratch,

Simple works

cmundi - May 31, 2009 - 21:06

Ok. I created a new content type called NewReview with *no* custom fields and enabled fivestar for it. Works like a charm.

I will eventually figure out what was going on, as I enhance NewReview with the custom fields I need.

When I figure it out I will report back here.

 
 

Drupal is a registered trademark of Dries Buytaert.