Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
I'm currently making a members section on the website. We run exclusive news and reports interviews and such like. I have made a folder within the news called Exclusive. I want to hide any news that goes into the folder Exclusive.

I'm currently showing the posts however i want to hide the exclusive folder from everyone else so i can then show them within members area.

Code: Select all
<cms:pages masterpage='news.php' folder=k_folder_name>
.....
</cms:pages>
Can you please let me know how you are implementing the member's area?
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.
Okay i get that and understand. Ran a test and works :-) Its perfect and very well explained

There is a second issue i have. On each page i want them to know they can login. Or if they are logged in. So i've ran this

Code: Select all
<cms:if k_logged_out >Welcome to the heart of automotive's. The life in the automotive scene<a href="<cms:show k_login_link />">Login</a> | <a href="register_member.php">Register</a></cms:if> 

<cms:else />

<cms:if k_logged_in >You're Logged in <span id="new1"><strong><cms:show k_user_title /></strong></span> <a href="<cms:show k_logout_link />">logout</a></cms:if>


Ok when logged in this shows, when logged out, it does not show. Confused really.
Try this
Code: Select all
<cms:if k_logged_in >
   You're Logged in <span id="new1"><strong><cms:show k_user_title /></strong></span> <a href="<cms:show k_logout_link />">logout</a>
<cms:else />
   Welcome to the heart of automotive's. The life in the automotive scene<a href="<cms:show k_login_link />">Login</a> | <a href="register_member.php">Register</a>
</cms:if>

Hope this helps.
KK wrote: Try this
Code: Select all
<cms:if k_logged_in >
   You're Logged in <span id="new1"><strong><cms:show k_user_title /></strong></span> <a href="<cms:show k_logout_link />">logout</a>
<cms:else />
   Welcome to the heart of automotive's. The life in the automotive scene<a href="<cms:show k_login_link />">Login</a> | <a href="register_member.php">Register</a>
</cms:if>

Hope this helps.


Worked first time. Getting to grips with ''if'' and ''else'' tags
7 posts Page 1 of 1
cron