Show which nodes are premium or not with views fields.

iaminawe - July 29, 2009 - 11:43
Project:Premium
Version:6.x-1.x-dev
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi,

Here is my use case and setup

I am using the Premium module, patched with the redirect patch here http://drupal.org/node/360054 and also with the Premium Views filter from http://drupal.org/project/premium_views_filter

My content type has a few cck fields and I am not using the default body field so I needed to implement the redirect url above to send someone to the correct page when they try and view premium content as the default setup only replaces the body field with the message and so was not working for me out the box.

I encountered a problem in that my views using node teasers were automatically sending a user to the login screen as soon as the view was displayed without the user clicking on anything. I was able to solve this by using fields rather than nodes in the view and everything is working great.

I would like to flag my premium content with an icon or color block or even with the word "premium" to differentiate what content is free and what is premium when they are listed together in a view.

There is a view field available for Premium which allows a user to choose whether it should be set to display, TRUE/FALSE, Yes/No or On/Off in the resulting view. This is great but how would I go about customising this output to read Premium/Free or even add two different bits of html code to display a premium icon or a free icon.

I have tried looking in the module code to override or add to these options but cannot find where they are being set.

I also tried to use the Views Customfield module http://drupal.org/project/views_customfield to take the output from the Premium Field (True/False) and pass it through to a conditional php statement which would output the custom message or icon dependent on the previous fields output.

I am not sure if my php is just terrible but I could not get this to work after many attempts as I could not find the correct variable from the $data variable that identifies whether a node is premium or not.

Any guidance here would be hugely appreciated as I have been on this issue for a while

 
 

Drupal is a registered trademark of Dries Buytaert.