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

Suppose,
I have two nos. data bound master page template one is employee.php and other one is employer.php. Both page have a common editable region name 'location'

<cms:editable name='location' required='1' type='text' />

Now what I want to achieve When location (India) matches it will display a list view with 'location'(india) when a employee or employer log into his/her own page .

I cant code this, but I tried simply
Code: Select all
<cms:pages masterpage='employer.php' && masterpage='employee.php'>                  
<cms:if location == location >
<cms:show location/>
...Other...
<cms:else />
</cms:if>
</cms:pages>


What is the right code ? I need your help.
Thanks
To help get this started. I have not tested, but try something this:

Code: Select all
<cms:set employer_location = "<cms:get_custom_field 'location' masterpage='employer.php' />" />   
<cms:set employee_location = "<cms:get_custom_field 'location' masterpage='employee.php' />" />   

<cms:if employer_location == employee_location >
   If Matches, do something
<cms:else />
   If doesnt, do something
</cms:if>

Hi john,
Thanks for your suggestions,

I tried as you suggest but its result always 'If doesnt, do something'.
Why because its always set a value from default page.
Code: Select all
<cms:set employer_location = "<cms:get_custom_field 'location' masterpage='employer.php' />" /> 


I set my default page unpublished. but it always display and set employer_location from default page.

Code: Select all
<cms:set employer_location = "<cms:get_custom_field 'location' masterpage='employer.php' />" /> 
<cms:show employer_location/>


Where I have 3 other pages set as published mode, with different value of employer_location.
One things more editable employer_location have four option value.. like India, USA, .., ..,

same thing happening with employee.php.

need help.
@Subhamoy,
As explained in the docs (http://docs.couchcms.com/tags-reference ... stom_field), we can use the 'custom_field' parameter of cms:pages to fetch pages based on values of editable regions.

For example, in your case if you were to put the following in any template, it should list all pages from 'employee.php' that have 'USA' as value of 'location' editable region -
Code: Select all
<cms:pages masterpage='employee.php' custom_field="location==USA">   
    <h2><cms:show k_page_title /></h2>
</cms:pages>

The example above has 'USA' hard-coded into the parameter.
You'd like to make this value dynamic - taken from the location of 'employer' or 'employee'.

Let us take only the employer for our example. You want that when an employer logs into her page, she should see a list of employees that have the location field matching that of her's.

I am not sure how exactly you have structured the login, but I'm sure you should be able to extract the 'location' of the logged-in user (using either the user's name or id). Let us know if you have difficulty in doing this.

So assuming that you have the employers location available in a variable named 'employer_location', the code we used above will now become -
Code: Select all
<cms:pages masterpage='employee.php' custom_field="location==<cms:show employer_location />">   
    <h2><cms:show k_page_title /></h2>
</cms:pages>

And now you should get a list of matching employees on the employer's page.

Hope it helps.
Thanks Sir. Its now working perfectly.
5 posts Page 1 of 1