By cameron32 on
Hi All,
I've been battling all day with trying to get Drupal to allow anonymous users view the first page of a taxonomy category with the node/page teasers, BUT require them to create an account when they click "read more" to view the actual page.
Simple access couldn't do it. Neither could taxonomy access control. Both of them were "all or nothing" in regards to viewing content, which isn't what I want. Surely there is a simple way to do this...?
I have run multiple searches and come up empty. I may be searching for the wrong phrases, and if so, just tell me the phrase I need to search or link me to the page discussing this.
Thanks,
Cameron
Comments
I don't know for sure
but have you looked at the premium module?
--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ
Game to write some PHP code?
Hi...
The "simple" way to do this actually requires coding in PHP, and as such is simple if you have the knowledge, but not if you don't! I am not aware of any modules that'll do this for you out-of-the-box.
If you're game to put a bit of PHP into your theme I would suggest wrapping a condition around the "read more" link to take the user somewhere else if they're not of the right role.
Let me know if you're interested in this approach and I'll dig out some code to give you a start.
Jeff
_________
http://marmaladesoul.com
I'm willing to give it a
I'm willing to give it a shot! I'm not a php programmer, but I can certainly tweak an existing bit of code. So please do dig that code up, Jeff.
Thanks!
Cameron
some code
OK, in your theme's node.tpl.php file, locate the following line:
<?php if ($links) { ?><div class="links">» <?php print $links?></div><?php }; ?>This is what prints the "read more" link (and other links as relevant). We'll wrap this:
» <?php print $links?>...in a condition to see if the user is anon or not. Replace the code above with the code below:
Hope this works for you... I've only roughly tested it.
Jeff
_________
http://marmaladesoul.com
You're the man
Eeeeeexcellent! Works great in firefox and IE. Thanks Jeff! I really appreciate the help and you taking the time to work out the code.
Best,
Cameron
Expanding on that
Is there a way to do this on a node by node basis? I have node access installed to be able to grant which nodes are to be alotted to authenticated users and which ones anon. So I need to have on the main category page where they have the teaser and they do have access to the full article and others that have the teaser but have to log in to read the rest. As cameron found, it seems to be all or nothing. The fix you mentioned would need to be modified though for an individual node, right?
yes
Hi,
The code I suggested above just looks at the user's role ID, and makes the decision based on that. There are a great many alternatives that could be used as the deciding factor. It would be quite straightforward to do it based on user role AND node type (book, page etc) for example.
However, I haven't used the node access module unfortunately, so I can't suggest a modification to work with that.
Jeff
_________
http://marmaladesoul.com
Is there any other way?
Is there any other way where it does not involve any coding?