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

Code: Select all
<cms:template title="My Title" />

Shows "My Title" in backend.

Code: Select all
<cms:set my_title="My Title" />
<cms:template title="<cms:show my_title />" />

Shows an empy name in backend.
I can not confirm this. Once template has been visited as superadmin for the changes to persist, backend's sidebar and template's title are showing whatever the variable contained.
Strange. Testing it with a minimal testcase, it works. It is not the first time, I struggle with such problems. And yes, I always visit the page as SuperAdmin to persist the changes.

I develop with ddev https://ddev.readthedocs.io/en/stable/, which uses MariaDB instead of MySQL. Could this be a problem?
When you encounter some weird behavior, you are welcome to zip everything and send me to test it. Often, problems do not reappear though, but I promise to test anyway.
Would you be so kind and check this test.php:
Code: Select all
<?php require_once('couch/cms.php'); ?>
    <cms:template title='News' clonable='1' />

    <cms:hide >
        <cms:if k_template_is_clonable='1' >
            <cms:set meta_title=k_page_title />
            <cms:else />
            <cms:editable name="meta_title" order="1" group="meta" label="Titel" type="text" />
        </cms:if >
    </cms:hide >

    <title ><cms:show meta_title /></title >
<cms:dump />
<?php COUCH::invoke(); ?>


First I got a two titles in backend. I fill in a title (k_page_tilte). After saving and previewing the page, I got the error "field not found". I delete it. But page title is still empty, even meta_title is set to k_page_title.

I am confused.
Well, at first glance the source of trouble appears when a new clonable template gets opened in browser the very first time (to get registered in backend) - and cms:dump outputs

k_template_is_clonable: 0

I could say it is not meant to be so. One is not expected to refresh the template in browser again to get the system variable correctly read from db. Perhaps, @KK should review the Couch code? Hopefully he can recreate the issue and would thank you later :)

The rest is obvious - the first time an editable gets registered because cms:else is taking the execution, the next time it gets removed, because template is recognized as clonable and editable's definition is not appearing anymore (considered deleted by user).

When this is fixed, I suggest to rewrite your snippet anyways, beacuse it is better to place editables inside cms:template block. And it would look like this (with one-liner setting of meta_title) -
Code: Select all
    <cms:template title='News' clonable='1' >
        <cms:if k_template_is_clonable='1' >
            <cms:editable name="meta_title" order="1" group="meta" label="Titel" type="text" />
        </cms:if >
    </cms:template>

    <cms:if k_is_page>
        <cms:set meta_title="<cms:get 'meta_title' default=k_page_title />"  />
    <cms:else />
        <cms:set meta_title=k_template_title />
    </cms:if>

    <title ><cms:show meta_title /></title >
Perhaps, @KK should review the Couch code? Hopefully he can recreate the issue and would thank you later :)

@trendoman, we have already been through this issue a while back -
viewtopic.php?f=8&t=11067
viewtopic.php?f=8&t=10109#p30153
As noted by you in your solutions above, when a page gets executed (which, incidentally, is also the point where all variables are set), there is no way of knowing about its eventual 'clonable' state - this is set much later in the flow when the <cms:template> tag executes.

This is one of those cases where you have to refresh the template for the changes (e.g. change clonable status) to persist and refresh once more for any dependent clauses to take effect.
@KK, can't cms:template tag update the context?
@KK, can't cms:template tag update the context?

Well, yes it can. However, then to maintain consistency, it'll also have to undo all variables that were set assuming a different clonable status and then reset them all according to the new status.

Can be done but ill require treading carefully.
9 posts Page 1 of 1
cron