Hi there,
My initial method handled several user groups and used the 'includeprefix=$customcontent_groups' part to pull the logged in users's group(s) and match this to pages with corresponding alias prefixes.
You will need to adjust all page aliases (just the prefix) and user groups to match each other, i.e. user groups like group01_, group02_ and page aliases like group01_private_content, group01_even_more_private and group02_really_secret.
In your case it should be easier. As I understand it you just have two user groups: 1) Logged in 2) Not logged in. You won't need to add the 'groups_to_prefixes' UDT and with just the two public pages you may even use the aliases for those, without a specific prefix.
Anway, you will have to fix the template for both the menu and the content:
An example for a top level menu
Code: Select all
{if $customcontent_loggedin > 0}
{cms_module module='menumanager' template='your_template' number_of_levels='1' includeprefix='about,register,priv_'}
{else}
{cms_module module='menumanager' template='your_template' number_of_levels='1' includeprefix='about,register'}
{/if}
You may also go
excludeprefix='priv_' instead of the second
includeprefix.
If you use a menu setup with top level and the rest in a sub menu, you would have to do the same thing for the sub menu and use standard syntax, e.g. start_level='2' collapse='1' in the menu call.
As I mentioned, the example above will not handle different user groups; just logged in and not logged in. If you would like to add that functionality,
CalGuy's way is indeed a good one - I use it myself.
The content
Now, you need to adjust the template for the content part of it all. I suggest you go for CalGuy's solution: adjusting the template, the optional metadata field for each private page and the alias for each private page. In your case, you probably want to adjust the code for the metadata field a bit compared to the original, since you don't need to check for specific user groups.
The private pages optional metadata field:
Code: Select all
{assign var='content_is_visible' value='0'}
{if $customcontent_loggedin > 0}
{assign var='content_is_visible' value='1'}
{/if}
You also need to change all private page aliases to include the prefix 'priv_'.
Use CalGuy's method for the template:
Code: Select all
{if !isset($content_is_visible)}
{* assume public content, unless the variable is already set *}
{assign var='content_is_visible' value='1'}
{/if}
{if $content_is_visible == '1'}
<h1>{title}</h1>
{content}
{else}
<div class="bigerror">You need to log in...</div>
{/if}
Don't forget to style the 'bigerror' in your CSS
The disadvantage of having to add the code lines to the metadata field in all private pages could be handled by using two content blocks in the template instead - one for public and the other for private content. You could even use two templates - one for the public pages where the {content} is just inserted as it is and the other for the private pages where the {content} is handled with custom content module standards:
Code: Select all
{if $customcontent_loggedin > 0}
{content}
{else}
<h1>You are not authorized to view this data</h1>
{/if}
CalGuy's method is based on just one template, which of course is effective as it let you forget about adjusting two templates when updating it.
I guess it's just a matter of taste and by whom the site will be managed - you or an editor. Personally, if the content will be updated by an editor, without knowledge about the tech stuff, I would go for two templates.
Good luck and please let me know if you get it to work as you want.
Happy holidays 