by
KK » Tue Aug 09, 2016 12:47 am
@ewanmc,
As mentioned in the introductory post, if we use the <cms:field> tag as a 'tag-pair', it makes it display anything that is enclosed within the pair e.g. the follows will always display 'hello!' -
- Code: Select all
<cms:field 'your_name' header='Name' >
hello!
</cms:field>
As also mentioned, the enclosed content is executed dynamically i.e. if it has regular Couch tags those would be parsed and executed just the way we see on the frontend templates.
So, for example, the following would always show the title of the page -
- Code: Select all
[code]<cms:field 'your_name' header='Name' >
<cms:show k_page_title />
</cms:field>[/code]
Which brings us to your immediate question (how to display the edit link).
One way would be to craft the edit link manually and display it.
Another would be to see if Couch already makes this link available and, if so, use it.
On a frontend template, to know exactly which variables are available at any point we can, as I am sure you know, we can place <cms:dump /> or <cms:dump_all /> tag at that point and this gives us a list of all the available variables.
We can do exactly that with the backend templates too. So, if we were to make your code as follows it will show you the entire list of variables at your disposal at that point (i.e. while displaying your field) -
- Code: Select all
[code]<cms:field 'your_name' header='Name' >
<cms:dump_all />
</cms:field>[/code]
In the list, you'll notice that there is a variable named 'k_update_link' that gives us the link to the edit screen of the page being iterated.
Use it in your code as follows and now you have the edit link you wanted -
- Code: Select all
<cms:field 'your_name' header='Name' >
<a href="<cms:show k_update_link />" >
<cms:show k_page_title />
</a>
</cms:field>
Substitute k_page_title to whatever you want to use as the text - I think it would be the 'your_name' field
- Code: Select all
<cms:field 'your_name' header='Name' >
<a href="<cms:show k_update_link />" >
<cms:show your_name />
</a>
</cms:field>
Hope it helps.
P.S. Make sure to visit the frontend template as super-admin each time you modify the code for it to be persisted.