Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi,

I have some folder and sub-folder

Like
A (Folder)
-1 (Sub-Folder)
-2 (Sub-Folder)
-3 (Sub-Folder)
...........(Sub-Folders)
-100 (Sub-Folder)

I am using this code

Code: Select all
<cms:if my_membership_type='A'>               
                     
                        <cms:input class="login-input" id="image20" name="image20" type="bound" />               
                                       
                     </cms:if>


In this case if I select Parent folder A above condition work perfect only if I set Parent Folder "A" in admin, but if i set sub-folder 100 above condition not working.
what is the exact code to working Parent and Sub folder with the above condition?
or I have to try ?
Code: Select all
<cms:if (my_membership_type='A') || (my_membership_type='1')|| (my_membership_type='2') || (my_membership_type='....') || (my_membership_type='100')>


Thanks
Subhamoy
I suspect you are going about implementing your functionality in a non-optimal way. With that said, the is_ancestor tag may be useful in this case -
Code: Select all
<cms:if my_membership_type == 'A' || "<cms:is_ancestor masterpage='members/index.php' parent='a' child=my_membership_type/>">
I am not understanding how you are setting my_membership_type so I may well have misunderstood your code.
Hi @ cheesypoof,

Thanks for your response

I used this code setting my_membership_type
Code: Select all
<cms:pages masterpage=k_member_template  id=k_member_id>
    <cms:set my_membership_type=k_page_foldername  'global' />   
</cms:pages>


in profile.php

kindly take look on viewtopic.php?f=4&t=9296&start=10
Ok
Now I configure above code in profile.php like this
Code: Select all
[code]<cms:pages masterpage=k_member_template  id=k_member_id>
    <cms:set m_t=k_page_foldername  'global' />   
</cms:pages>[/code]


And after that I am using If condition like this
Code: Select all
<cms:if (m_t='dynamic') || (m_t='dcat1') || (m_t='dcat2') || (m_t='dcat3')|| (m_t='dcat4')|| (m_t='dcat5')|| (m_t='dcat6')|| (m_t='dcat7')|| (m_t='dcat8')|| (m_t='dcat9')|| (m_t='dcat10')|| (m_t='dcat11')|| (m_t='dcat12')
|| (m_t='dcat13')|| (m_t='dcat14')>
<cms:input class="login-input"  id="first-videolink1" name="videolink1" placeholder="Enter Video link 1 from youtube." type="bound" value="" />
</cms:if>


So I want to short above code. because If I reach to dcat200 then code will be increase.

Here dynamic is a parent folder of dcat1(dynamiccat1) - dcat14 (dynamiccat14)

Hope you understand what I want to mean.



Thanks
Subhamoy
@Subhamoy, going by the info you provided in your original thread (viewtopic.php?f=4&t=9296&start=10), your folder structure would be something like this -
Diamond
Gold
- Actor
- Model
Silver
- Actor
- Model
- where only the top level folders represent the 'membership type'.

Your problem now is that for a page (member) belonging to folder 'Model' or 'Actor', you'd need to know the top-most parent of the folder to get the membership type.

To get all the parents of a folder we can use the cms:parentfolders tag -
Code: Select all
<cms:parentfolders folder=k_page_foldername >
   .. lists all parents of the specified folder ..
</cms:parentfolders>

To single out the top-most folder from the list above we can place a check as follows where we single out the folder that has no parent (this has to be the top-most folder) -
Code: Select all
<cms:parentfolders folder=k_page_foldername >
    <cms:if k_folder_parentid='-1'>
        .. this is the top-most folder ..
    </cms:if>
</cms:parentfolders>


With that clear, we can now amend your code from the existing -
Code: Select all
<cms:pages masterpage=k_member_template id=k_member_id>
    <cms:set my_membership_type=k_page_foldername 'global' />
</cms:pages>

- to the following -
Code: Select all
<cms:pages masterpage=k_member_template id=k_member_id>
    <cms:parentfolders folder=k_page_foldername >
        <cms:if k_folder_parentid='-1'>
            <cms:set my_membership_type=k_folder_name 'global' />
        </cms:if>
    </cms:parentfolders>
</cms:pages>

Now the 'my_membership_type' variable will always hold the top-most folder's name.

Hope it helps.
4 posts Page 1 of 1