Problems, need help? Have a tip or advice? Post it here.
14 posts Page 2 of 2
Thanks.

The most straightforward solution, I think, would be the use of folders as I initially suggested.

If we go by the docs (viewtopic.php?f=5&t=8063), the 'members' template (i.e. the template the cloned pages of which represent actual member accounts) and the 'profile' template (i.e. where the logged in user can modify her own data) are two distinct entities.

Let us keep it the same way.
So let us suppose the members template is named 'members.php' and the profile is 'profile.php'.

The config will have the following entry -
Code: Select all
$t['members_tpl'] = 'members.php';  


In the 'members.php', define folders for the membership type (e.g. 'gold' and 'silver').
Also define editable regions for *all* membership types.

The last point is important for you to understand as that is where you had the most difficulty.
Create all editable regions in the single template. So for example the 'designation' field will be shown only to 'gold' members, yet define it with all the other regions. A sample implementation -
// members.php
Code: Select all
<cms:template title='members' clonable='1'>

    <cms:editable
        name='name'
        label='Name'
        desc='Enter Your Name'
        type='text' />

    <cms:editable
        name='designation'
        label='Designation'
        desc='Enter Designation Here i.e. Actor, Makeup artist etc.'
        type='text' />

    <cms:folder name='gold' title='Gold' />
    <cms:folder name='silver' title='Silver' />

</cms:template>

I am now assuming that (as you informed me), the admin will place each member account in one particular folder (e.g. gold or silver).

So now let us move to the 'profile.php' template.
We'll make one small modification to it. Just above the databound form, we'll place the following code -
Code: Select all
<cms:pages masterpage=k_member_template id=k_member_id>
    <cms:set my_membership_type=k_page_foldername 'global' />
</cms:pages>

The code above will simply set the current logged-in users folder (i.e. the membership type) in a variable named 'my_membership_type'.

So now while showing the form we can make use of the variable we got above to show/hide certain fields in the form depending on the membership type of the user.

In our example we had assumed that the 'designation' region will be shown only to 'gold' members. We can do that by a simple check as follows -
Code: Select all
<cms:if my_membership_type='gold' >
    <p>Enter Designation:</p>                 
    <cms:input class="login-input"  id="designation" name="designation" placeholder="Your designation" type="bound" value="" />
</cms:if>

The full code would look like this (showing only the relevant parts) -
Code: Select all
..
<cms:pages masterpage=k_member_template id=k_member_id>
    <cms:set my_membership_type=k_page_foldername 'global' />
</cms:pages>

<cms:form
    masterpage=k_member_template
    mode='edit'
    page_id=k_member_id
    enctype="multipart/form-data"
    method='post'
    anchor='0'
    class="login"
    >
   
    ..
    ..
   
    <p>Enter Name:</p>
    <cms:input class="login-input"  id="first-name" name="name" placeholder="First Name  Last Name" type="bound" value="" />

    <cms:if my_membership_type='gold' >
        <p>Enter Designation:</p>                 
        <cms:input class="login-input"  id="designation" name="designation" placeholder="Your designation" type="bound" value="" />
    </cms:if>

    <input style="width:200px;"  type="submit" name="submit" class="login-submit" value="Save"/>
</cms:form>   
..

I think you should be able to adapt the technique to your own requirement.

Hope it helps.
Awesome, thanks KK Sir,

Its working fine..

Thanks and thanks again

I have two more question

1) If increase one more membership type named "Diamond"
and I use
Code: Select all
<cms:if (my_membership_type='gold') && (my_membership_type='diamond')>
                     <div  <cms:if k_error_resume >has-error</cms:if>">
                        <label class="control-label" for="image3">Upload Your Profile 3rd Picture </label>
                        <cms:input class="login-input" id="image3" name="image3" type="bound" />               
                     </div>
                     
                </cms:if>


the above code not working.

2) If I use Dynamic folder

Gold & Silver member have some child folder eg

Diamond
Gold
- Actor
- Model
Silver
- Actor
- Model

I know that for list view
Code: Select all
<cms:pages masterpage=''members.php' folder=k_folder_name > 

Code: Select all
<cms:pages masterpage=''members.php' folder=gold > 

but what will be the code for child view?

Thanks
Subhamoy
Code: Select all
<cms:if (my_membership_type='gold') && (my_membership_type='diamond')>
The code above will translate to "If membership is 'gold' AND also 'diamond' - do this".
Obviously, in your case a person cannot hold both types of memberships at the same time so the condition above will never be met.

The right condition should be "If membership is either 'gold' OR 'diamond' - do this".
The code for it -
Code: Select all
<cms:if (my_membership_type='gold') || (my_membership_type='diamond')>


Regarding the second question, all folders (child or otherwise) have a unique name (for dynamic folders you can get the names from their edit screens). You can use the name of the specific sub-folder e.g.
Code: Select all
<cms:pages masterpage='members.php' folder='gold-actor' > 

But I suppose your question was not about hard-coding the folder's name. Rather, it was about the 'k_folder_name' variable used as the parameter -
<cms:pages masterpage=''members.php' folder=k_folder_name >

The code above is meant for a folder-view (i.e. when a visitor clicks a link for a folder to access the template) and will continue to work with sub-folders also. The 'k_folder_name' variable will automatically hold the name of whatever folder/sub-folder is being accessed.

Hope it helps.
Thanks KK, you make my day.
14 posts Page 2 of 2
cron