Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
I am having an issue getting a custom editable field to display on a page in my website. I have tried different combination of <cms:show /> and <cms:get_custom_field />, but am having no luck. I suspect it is because I am still trying to grasp clonable pages. I am creating a client section that will display links to different users. I will use the admin panel to write in different links in each user, and I want it to display on the users page.

Here is my users/index.php file:
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>

<cms:template clonable='1' title='Users' hidden='1' parent='_user_module_'>
    <!--
        If additional fields are required for users, they can be defined here in the usual manner.
    -->       
                <cms:editable name='firstname' required='1' title="First Name" type='text' />
                <cms:editable name='lname' required='1' title='Last Name' type='text' />
                <cms:editable name='phone' required='1' title='Phone Number' type='text' />
                <cms:editable name='company' title='Company Name' type='text' />
                <cms:editable name='website' required='1' title='Website URL' validator='url' type='text' />
                <cms:editable name='links' title='Links' type='richtext' />

</cms:template>

<?php COUCH::invoke(); ?>


How do I get the 'links' to show on another page as just a read only. Can someone point me in the right direction?
Hi :)

I think it should be clear to you that for a clonable template, when one logs into the admin-panel and inputs data in the editable regions defined for that template, she is always saving the data in the context of some 'cloned page' (as opposed to the template itself).

That is to say that, suppose the template has six cloned pages, each of the six will show the same editable regions but will have its own data.

So, to retrieve data from a clonable template we need two pieces of info - 1. the template's name and 2. a specific page's unique identification (this could be either its 'id' or 'page_name').

With that understood, I think it should also be easy now to what the following code is doing -
Code: Select all
<cms:pages masterpage='users.php' id='210' >
    <cms:show firstname /><br>
    <cms:show lname /><br>
    <cms:show phone /><br>
</cms:pages>

or
Code: Select all
<cms:pages masterpage='users.php' page_name='jane_doe' >
    <cms:show firstname /><br>
    <cms:show lname /><br>
    <cms:show phone /><br>
</cms:pages>

Code above assumes that the template name is 'users.php' and the particular cloned page we are looking for is named 'jane_doe' (and has an 'id' of '210').

You can place the code above on *any* Couch managed template and it should fetch the data you entered for 'jane_doe'.

Does this help?
@KK This was perfect! I understand it much better now. I was able to change

Code: Select all
id='210'


to

Code: Select all
id=k_user_id


to dynamically pull the logged in users information! :D
I am glad it helped :)
4 posts Page 1 of 1