Closed (fixed)
Project:
Premium
Version:
4.7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Jul 2006 at 18:16 UTC
Updated:
19 Jul 2006 at 16:44 UTC
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
Comment #1
allie mickaIt'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?
Comment #2
arthurf commentedPerhaps 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?
Comment #3
allie mickaOK, 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!