Forum for discussing general topics related to Couch.
7 posts Page 1 of 1
Code: Select all
<cms:if headline_de><cms:show headline_de /></cms:if>
<cms:if headline_en><cms:show headline_en /></cms:if>
<cms:if headline_fr><cms:show headline_fr /></cms:if>
<cms:if headline_es><cms:show headline_es /></cms:if>
<cms:if headline_it><cms:show headline_it /></cms:if>


How can I rewrite the code above into an one-liner?
I had the idea of writing a func like this:

Code: Select all
<cms:func _into='is-set-with-lang' varname=''>
    <cms:capture into="output">
        <cms:get name="<cms:show varname />_<cms:show k_lang />" />
    </cms:capture>

    <cms:if output != ''>true<cms:else />false</cms:if>
</cms:func>


Then I could use the call function:

Code: Select all
<cms:call is-set-with-lang varname="headline" />
<cms:if is-set-with-lang=="true"><cms:get name="headline_<cms:show k_lang />" /></cms:if>


But this does not work :(
Try this -
Code: Select all
<cms:each k_supported_langs as='lang' key='lc'>
    <cms:get "headline_<cms:show lc />" into='my_headline' />
    <cms:if my_headline><cms:show my_headline /></cms:if>
</cms:each>

Hope it helps.
Yes, this helps a lot. :D
How can I access the right scope of k_supported_langs, when using repeatable? This does not work.
Code: Select all
<cms:repeatable name='tiles'>
    <cms:each k_supported_langs as='lang' key='lc'>
        <cms:editable name="title_<cms:show lc />" label='Titel' desc=lang type='text'  />
    </cms:each>
</cms:repeatable>
It shouldn't. You are using unsupported tags inside definition of Repeatable Region. It is not a matter of scope.

SimonWpt wrote: How can I access the right scope of k_supported_langs, when using repeatable? This does not work.
Code: Select all
<cms:repeatable name='tiles'>
    <cms:each k_supported_langs as='lang' key='lc'>
        <cms:editable name="title_<cms:show lc />" label='Titel' desc=lang type='text'  />
    </cms:each>
</cms:repeatable>
AI ChatGPT is pretty smart. I guess it can be trained on "CouchCMS template language" :lol:

Screenshot-2023-03-20-034746.540.png
Screenshot-2023-03-20-034746.540.png (13.64 KiB) Viewed 1431 times
7 posts Page 1 of 1