I have 3 view modes (teaser, presentation and full view mode). I have created a node--content-type.tpl.php and created the code for each view mode using a conditional statement

if($teaser) {} 
else if($node->type == 'tu_mooc' && $view_mode == 'presentation') {} 
else {}

I have linked the 3 view modes. So I can go from the teaser to the presentation and from the presentation to the full view mode.

I have downloaded the premium content module so that access to the full view mode is limited to authenticated users. I made a small change in premium.module so that anonymous users have access to both the teaser view mode and the presentation view mode. The problem I have is that when I try to access the full view mode (as an anonymous user) I don't get the access denied message. Instead I get the code that appears within the teaser view mode. i.e. In node/1 I get the teaser of node1 instead of getting the access denied message.

Do I need to include some code like <?php print $denied_message; ?> into the node--content-type.tpl.php? or what do I need to do?

Thanks in advance.


I have included this code within the teaser in node--content-type.tpl.php:

<?php print $content['body'][0]['#markup']; ?>

And I have included this code in template.php:

function  mimooc_premium_body($arguments) {
  $node = $arguments['node'];
  node_build_content($node, 'teaser');
  $level = premium_level_load($node->premium);
  if ($level->denied_message) {
    $denied_message = $level->denied_message;
    $denied_message_format = $level->denied_message_format;
  else {
    $denied_message = variable_get('premium_message', t('Full text available to premium subscribers only.'));
    $denied_message_format = variable_get('premium_format');
  // Only display the premium message, if we actual have any content.
  if (!empty($node->content)) {
    return '<div class="premium-message"><h3>' . check_markup($denied_message, $denied_message_format) . '</h3><p>' . l('Click here to sign in', 'user') . '</p></div>';

Now, when I access the full view mode of the node, I get the teaser of that node with the access denied message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.