Following on from #441396: Restrict content on full page views only I'd like to be able to show a truncated $node->content when viewing a full node before showing a registration / upgrade message.

CommentFileSizeAuthor
#2 restricted_content.module.txt10.67 KBtriblondon

Comments

triblondon’s picture

I'm working on a patch for this at the moment.

triblondon’s picture

StatusFileSize
new10.67 KB

OK, I've made significant progress with this. I've actually made a lot of changes to the module, mainly comprising:

1. Change to barrier page configuration to separate the two templates - one for logged in users, one for logged out users. We want our barrier pages to be completely different if you are not logged in at all.

2. I was confused by the fact that the ability to define access restrictions on a node automatically gave you the right to view the public version of the node, even if your user account did not have one of the roles that was allowed to view it. For our users it makes sense for this to be decoupled, and it also gives the editing user an easy way to see the effect of their access restrictions from the point of view of someone (themselves) that doesn't have access (the edit tab still appears and allows the user to edit the node).

3. I've added a [teaser] token that is populated with the node's teaser even in full page view mode, so that you can include the teaser in the barrier page.

4. Added tokens for [restricted-content-roles-required-list] and [restricted-content-roles-required-list-with-prefix]. These produce output such as "Editor, Webmaster or Member" and "an Editor, Webmaster or Member". The with-prefix bit just means the module makes the decision about whether to prepend an 'a' or an 'an' for you.

5. Added [site-login-url] along with [site-register-url], and modified both to contain a 'destination=' querystring parameter so that the user is redirected back to the content they originally wanted once logged in / registered.

This has somewhat outgrown a patch - in fact I've also added hundreds of lines of comments and function documentation, and renamed various bits to suit out implementation, but you're very welcome to the code if you want to integrate it into the module. Attached.