Hey guys, wasn't sure where to put this, I had a bit of code that I couldn't find any info for on the net that might come in useful for someone that stumbles across this. I'm not a programmer so *disclaimer* it might not be pretty, it might be damn ugly and wrong but it does work! ;P You place it in your node.tpl.php file in place of $content


<?php if ($teaser): ?>

<?php
global $user;
// if visitor is not logged in
if (!$user->uid) {
// print the teaser
print $content;
} else {
// if user is logged in print the teaser
print $content;
}
?>

<?php elseif (!$teaser): ?>

<?php
global $user;
// if anonymous visitor and content type is all except blog or page
if (!$user->uid && $node->type != 'blog' && $node->type != 'page') {
// lock anonymous visitors out of the full article
print("<div class='messages'>Please <a href='/user/register'>register</a> or <a href='/user'>login</a> to view images!</div>");
} else {
// show all content for all content types to logged in users
print $content;
}
?>

<?php endif;?>

And you can see how it works on http://www.photosfordesigns.com

Comments

hilary_’s picture

Project: Content Access » Drupal core
Version: 5.x-1.5 » 5.12
Component: Code » node system
dpearcefl’s picture

Status: Active » Closed (won't fix)

Considering that no new tasks will be completed against D5 and that no one has shown any interest in this issue for a long time, I am closing this issue ticket.

quietone’s picture

Version: 5.12 » 5.x-dev
Issue summary: View changes
Issue tags: -, -teaser, -force login full node