Problems, need help? Have a tip or advice? Post it here.
13 posts Page 2 of 2
Okay, so I've registered all the members modules and they all seem to be working fine. I made a change to the members/index.php file's template statement to include dynamic_folders='1', and made a "Hockey" folder, with a test user inside of it.

I believe I'm on the right track with what you're saying.

My next question is, how do I check the folder on the front-end, for instance

<cms:if k_loggedin_folder='Hockey'>
Show edit link
<cms:else />
Not allowed!
</cms:if >

or along those lines.

Basically I want it to check the folder of the currently logged in member to grant access to the corresponding section.

Or I could have asked simpler

As for the 'groups', one simple way to get that functionality could be as follows -
since the members now are basically simple pages, you can create 'folders' to represent the groups. Assign members to respective folders and now you can place a check on templates to see if the visiting member belongs to a particular folder before granting access.


How do I do this?

I looked over the thread with installation instructions and <cms:member_*** > functions but didn't see anything that pertained to folder checking.
If you have followed the short tutorial in the member module's post, all your access protected templates would have something like this at the very beginning -
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>

    <!-- check the login status of the visitor -->
    <cms:member_check_login />

    <!-- if not logged-in, redirect her to the login page -->
    <cms:if k_member_logged_out >
         <cms:redirect "<cms:member_login_link />" />
    </cms:if>

The code above simply checks if a member is logged-in or not redirecting the non-logged visitors to the login page.

Let us add some code just after the lines given above to make it as follows -
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>

    <!-- check the login status of the visitor -->
    <cms:member_check_login />

    <!-- if not logged-in, redirect her to the login page -->
    <cms:if k_member_logged_out >
         <cms:redirect "<cms:member_login_link />" />
    </cms:if>
   
    <!-- at this point we have a logged-in user. Let us check if the account belongs to the right folder -->
    <cms:pages masterpage=k_member_template id=k_member_id>
     
      <!-- we have all data (i.e. regions defined in members template) about the current member here -->
       
       <!-- we'll store the folder in a global variable -->
       <cms:set my_member_folder=k_page_foldername 'global' />
       
    </cms:pages>

As you can see, we use cms:pages tag to fetch the cloned page representing the logged-in user. We can extract data from all editable regions defined in the member's template here. For our purpose we just pull out the folder name and save it in a global variable named 'my_member_folder'.

Now further on in the template we can simply check if the 'my_member_folder' variable matches the folder that has access permissions e.g. like this -
Code: Select all
    <cms:if my_member_folder='hockey' >
       
       .. whatever action is allowed ..
       
    <cms:else />
        <h2>Not allowed!</h2>
    </cms:if>

Hope this helps.
Perfect! Thank you! I took a look over it before my first cup of coffee this morning, so I'd figured it was best not to reply then, ahah.

Looks like it will work just fine for what I need. Now I just have to decide design aspects, such as an inline content management menu (Create, Edit, etc). The members module page and databound forms documentation should be all I need to finish up!

Can I recommend you guys add all of this to a tutorial on the main site (obviously polished up and generalized)? This is a HUGE functionality advantage over other "editable region" CMS'. I'm glad I chose couch :)
13 posts Page 2 of 2
cron