by
KK » Sat May 12, 2012 9:22 pm
OK, so you have a folder named 'exclusive' and you wish to restrict non-members from accessing it.
There are actually three different scenarios where you'd want to restrict access to the this folder -
1. While listing all folders (e.g. in the menu), you'd want to hide the link to this folder from all non-members.
2. While listing all pages of the template you'd want to hide pages within this folder from all non-members.
3. Finally, you'd want to disallow non-members to access directly any page within this folder.
Of the three situations listed above, the third one (disallowing access to single pages) can be easily implemented by setting 'Access permission' (advanced settings in admin-panel) for every page within the folder to 'Authenticated User'.
The remaining two situations can be tackled as follows -
1. Hiding from a list of folders:- Code: Select all
<cms:folders exclude="<cms:if k_user_access_level lt '2' >exclusive</cms:if>">
<a href="<cms:show k_folder_link />"><cms:show k_folder_title /></a> <br>
</cms:folders>
Note how we set the 'exclude' parameter to 'exclusive' for all uses who are not 'Authenticated users' (i.e. less that '2').
2. Hiding from a list of pages:We'll have to tackle the different views separately e.g.
- Code: Select all
<cms:if k_is_page >
</cms:else>
<!-- Here is where we normally list our pages. We'll tackle the folder-view seperately -->
<cms:if k_is_folder >
<cms:else />
</cms:if>
</cms:if>
This is how we can implement the access restrictions-
- Code: Select all
<cms:if k_is_page >
</cms:else>
<!-- Here is where we normally list our pages. We'll tackle the folder-view separately -->
<cms:if k_is_folder >
<cms:if k_folder_name='exclusive' && k_user_access_level lt '2' >
You need to be logged in as an authenticated User to access this area <p>
Please <a href="<cms:show k_login_link />">Login</a>.
<cms:else />
<cms:pages folder=k_folder_name >
<h3><a href="<cms:show k_page_link />"><cms:show k_page_title /></a></h3>
</cms:pages>
</cms:if>
<cms:else />
<cms:pages folder="<cms:if k_user_access_level lt '2' >NOT exclusive</cms:if>" >
<h3><a href="<cms:show k_page_link />"><cms:show k_page_title /></a></h3>
</cms:pages>
</cms:if>
</cms:if>
Note how in the folder-view, we first check if it is the restricted folder and the user is authenticated or not
and in the other listings we exclude the 'exclusive' folder for all non-authenticated users.
Hope this helps. Please let me know.