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
Comment #1
hilary_ commentedComment #3
dpearcefl commentedConsidering 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.
Comment #4
quietone commentedUpdating tags per Issue tags field and Issue tags -- special tags and for issue #3565085: Drupal core issue tag cleanup.