If you don't use $body and $teaser in your nodes, premium can be a bit tricky to use. If you modify theme_premium_body($node) in premium.module, you can better support content display based on premium access:

/**
 * Reformat the message body with a premium content message
 */
function theme_premium_body($node) {
  $node->premium_display = true;
  $node->teaser = $node->teaser .variable_get('premium_message','');
  return $node->teaser;
}

This gives much more flexibility to control layouts of node types. For example in node.tpl.php

 if ($node->premium_display == 0) {
     print $node->field_body[0][view];
  }
  else {  	
  	  print  $node->field_teaser[0][view]; 
  	  print '<strong>' . variable_get('premium_message', t('Full text available to premium subscribers only')) . '</strong>';
  }

Comments

allie micka’s picture

It's not clear why you are setting an additional variable and not just using $node->premium in your node.tpl.php file. This variable should exist for all nodes, and be true/1 if the item is actually premium. Have I missed something?

arthurf’s picture

Perhaps I misunderstand, but what I thought was that $node->premium just lets us know if the node is set to premium, not whether or not the current user has access. What I was trying to achieve was allowing for more complex theming choices based on the user, not on the node. Does that help clarify?

allie micka’s picture

Status: Active » Closed (fixed)

OK, that does help clarify. I can understand the need for this, but variable-setting has no business living in a theme function.

Instead, look for a boolean $node->premium_access in the now-updated cvs/4.7 code.

Thanks!