I am using the premium module to flag certain stories as Premium Content. I'd like to have those stories show an icon next to them as a visual reference to which ones are premium and which aren't.

<?php
  if($node->premium) print "<img src=\"/images/pc-logo.gif\" border=\"0\" height=\"15\" width=\"15\" alt=\"premium content\">";
?>

This is the code I'm using, which I believe to be valid, but no icon is being generated next to the premium stories. Any ideas as to why?

Comments

casey’s picture

  1. You have to use $data, not $node;
  2. Have you added the Premium field to the view?
  3. It possibly has another name than $data->premium; try print_r($data) first
djudd’s picture

Thanks casey, I guess I didn't have as much of an understanding of this module as I thought. I wasn't aware that the condition needed to be be added to the fields.

For anyone else who needs to do what I have done, here's the basics...

I added premium to my field, and set it to excluded from the display type, because it's output is just plain ugly.

I have then added this code to my Customfield: PHP Code statement:

<?php
  if($data->premium_nid) print "<img src=\"/images/pc-logo.gif\" border=\"0\" height=\"15\" width=\"15\" alt=\"premium content\">";
?>

And it works.

casey’s picture

Status: Active » Fixed

You're welcome.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.