Problems, need help? Have a tip or advice? Post it here.
14 posts Page 2 of 2
I can see two problems with your code -

1. You have not specified a 'scope' with <cms:put> - this is making it use its default setting and set a new variable *within* the local scope (i.e. within the <cms:related_pages ></cms:related_pages > block itself) and not in the array that is defined outside that block.

To make it target the outside array, please set the proper scope ('parent' in this case) as follows
Code: Select all
<cms:put "activetags.<cms:show k_page_id />nr" value="active"  scope='parent' />

To make sure the array has been populated as expected, use the following (after the <cms:related_pages ></cms:related_pages > block) temporarily to dump its contents -
Code: Select all
<cms:show activetags as_json='1' />

2. In the code where you are trying to retrieve back the values through <cms:get>, you have used a single-quote to set the tag's parameter -
Code: Select all
<cms:get 'activetags.<cms:show k_page_id />nr' />

This will prevent the enclosed <cms:show> from being evaluated and will not result in the correct variable name.
Please change that part to use 'double-quotes' instead e.g. as follows -
Code: Select all
<a class="<cms:get "activetags.<cms:show k_page_id />nr" />" href="<cms:show k_page_link />"><cms:show one_tag /> </a>

Please see https://docs.couchcms.com/concepts/sett ... eters.html if you are unsure about the single-quote/double-quote thing.

With the two changes, I think your code should work as expected.
Do let me know.
KK wrote: I can see two problems with your code -
(...)
Please see https://docs.couchcms.com/concepts/sett ... eters.html if you are unsure about the single-quote/double-quote thing.

With the two changes, I think your code should work as expected.
Do let me know.


Excellent! Yes, I was unsure about the single or double quotes, and had tried the variations but perhaps when I still had other things in there causing trouble.

Indeed it is working as it should now, thanks very much for helping out and pointing at what I was missing. Very helpful.
You are welcome :)
Thijs wrote: Thank you @trendoman, this is definitely much more efficient than my attempted roundabout code, and does perfectly what it's supposed to.

Indeed it is. Look forward to see your website showcased.
14 posts Page 2 of 2

Who is online

In total there are 15 users online :: 0 registered, 0 hidden and 15 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 15 guests