Important announcements from CouchCMS team
59 posts Page 6 of 6
Previous 1, 2, 3, 4, 5, 6 Next
It might not be obvious, but here is a tip for working with conditional fields, where the amount of values in selectors is overwhelming (like, more than 5).

Code: Select all
<cms:func _into='my_cond' long_tiresome_list_of_values=''>
    <cms:if long_tiresome_list_of_values > '=' >show<cms:else />hide</cms:if>
</cms:func>


Above code will show dependant if any selected value in long...list selector starts with a letter. And will hide it otherwise i.e. if it starts with a digit. This trick makes possible to show input on "KX-1209" and hide input on "2842" in the same list. It would be crazy to code all 12765 values in one func separately :lol:

A similar rule may be applied to individual letters: < 'x' will show everything that has as the first symbol a number or A to Z and a to w and will hide x, z and y (case-sensitive). Capital letters are separated with ^ from lowercase ones. For any specific rule, ask here or just review your codepage table.
Is there any way to code k_page_name (or similar) as a controller field? What I'm looking to do is not overwhelm users with choices until the basic page (title, text, image) has been saved into a page.

Once the page with the basic information is saved k_page_name, etc variables are created and those text fields and other vars are no longer empty.

User example: User/Admin clicks "Add New" to create a page. She should only see the basics - title, name, folder - then my user editable text, image. Once all of that has been saved (and the page reloads upon saving) then my "Display Options" group shows up with all the user choices on how to display this page's info into different mods for the site.

What I was hoping that I could use if not empty k_page_name as a controlling function, but that's not working. I'm at a loss on how to use the system vars as a controller. Is this possible?
@scratz

Perhaps the following would help?
viewtopic.php?f=8&t=13527

For your case, you can try using the following code within <cms:config_form_view> block to skip certain fields while the page is still new -
Code: Select all
<cms:jit_fields>
    <cms:if k_page_id eq '-1'>
        <cms:field 'my_field_a' skip='1' />
        <cms:field 'my_field_b' skip='1' />   
    </cms:if>
</cms:jit_fields>

Do let me know if it helped.
@KK,

I can't help but note the timing of your post. If you created this tag to solve my issue, I am truly humbled that you would take the time for such a drastic solution. I'm very happy that it has helpful cases beyond what I need.

The jit_fields tag works for me in this case, thank you. However, the skip='1' param didn't work so I used the following code:
Code: Select all
<cms:config_form_view>
    <cms:field 'display_opts' hide='1' />

    <cms:jit_fields>
        <cms:if k_page_id ne '-1'>
            <cms:field 'display_opts' />
        </cms:if>
    </cms:jit_fields>
</cms:config_form_view>


The reason skip didn't work is because that field 'display_opts' is type='group' which holds all contextual options for the user to choose how they want the page displayed. When 'skip' is used, only the group field is hidden and all of the options inside the group still show up. However, when I 'hide' under 'new/create' view, but display when k_page_id ne '-1', everything displays as intended.
(the hide param is explained in the post KK mentioned - viewtopic.php?f=5&t=10241 under Customizing the Form screen)
Thank you again KK and amazing team for your incredible determination to make CouchCMS the absolute best CMS system out there!
You are welcome @scratz and thanks for the feedback :)
Hello Amazing Couch Team and community:


I have a baffling case of conditional fields acting oddly in a page building mosaic. I'm not sure if the page builder part has anything to do with it, but it sure looks like the mosaic part does. I've read through this post and I don't see anything related to what's happening here.

THE ISSUE: Conditional checkbox to show/hide a group. It works as expected when the func is written as hide/show, but not as show/hide.

When it's written like hide/show:
Code: Select all
 <cms:editable type="row" name="bnr_hdr_choice" order="5">
    <cms:editable type='checkbox' name='bnr_hdr' label='No Section Header' desc='default = no section heading, check to add header'
        opt_values='Add Header=1'
        class='col-md-12'
        order='8'
    />
    <cms:func _into='bnr_hdr_yes' bnr_hdr=''>
        <cms:if "<cms:is '1' in=bnr_hdr />" >
            hide
            <cms:else />
            show
        </cms:if>
    </cms:func>
</cms:editable>
<cms:editable type="group" name="bnr_hdr_grp" label="Section Heading Group" not_active=bnr_hdr_yes order="13">
    <cms:editable type="row" name="bnr_hdr_row"  order="15">
....
</cms:editable>
</cms:editable>


When it's written like this, on the editable tile, the group "bnr_hdr_grp" displays and will disappear once 'bnr_hdr' is checked. This would be expected behavior the way the function is written. Upon clicking, bnr_hdr becomes '1' and the group which is labeled as not_active in this condition, hides.

But for me, my default needs to be the bnr_hdr_grp NOT displaying when the editable tile renders, but only displaying when the box is clicked, and for the checkbox to display unchecked by default. So when I swap the show/hide rules...

Code: Select all
<cms:func _into='bnr_hdr_yes' bnr_hdr=''>
        <cms:if "<cms:is '1' in=bnr_hdr />" >
            show
            <cms:else />
            hide
        </cms:if>


...the bnr_hdr_grp group does not display when the page renders (this is expected), however, it still won't display even as the checkbox is checked.

When I put this code on a regular page (ie, not a mosaic or page builder, but a regular template page with all code on one page) everything works exactly as expected.

Another troubleshooting technique was to remove all "header" and "tail" code and every bit of editable code except the group editable itself, making sure all elements were the correct hierarchical order in case there was something css or js related interfering. There was no difference in the group not showing up when the checkbox is checked. It appears to be something inherent with this setup in the mosaic or page builder.

Since this is happening in the back end, I'm not sure exactly what parts of the mosaic or page builder code to troubleshoot. Has anyone else experienced anything like this?
@scratz, thanks for the heads-up.
I'll look into it to see if it's a bug.
Hello @KK,
I'll look into it to see if it's a bug.

Any luck into finding out if this is a bug? Are you able to reproduce the issue?
Hi @scratz,

Sorry for the delay.
I tested the following code out as a tile in a mosaic and things work just fine (the group appears/disappears in concert with the checkbox) -
Code: Select all
<cms:tile name='scratz' label='Scratz'>
    <cms:editable type="row" name="bnr_hdr_choice" order="5">
        <cms:editable type='checkbox' name='bnr_hdr' label='No Section Header' desc='default = no section heading, check to add header'
            opt_values='Add Header=1'
            class='col-md-12'
            order='8'
        />
        <cms:func _into='bnr_hdr_yes' bnr_hdr=''>
            <cms:if "<cms:is '1' in=bnr_hdr />" >
                show
            <cms:else />
                hide
            </cms:if>
        </cms:func>
    </cms:editable>

    <cms:editable type="group" name="bnr_hdr_grp" label="Section Heading Group" not_active=bnr_hdr_yes order="13">
        <cms:editable type="row" name="bnr_hdr_row"  order="15">
            <cms:editable name='html' label='HTML' type='textarea' no_xss_check='1'/>
        </cms:editable>
    </cms:editable>
</cms:tile>

So, nothing wrong with the code per se.
As to then what could explain the behaviour you reported? I'd say, perhaps the particular arrangement of the tiles that you have is producing a glitch.
Please PM me the full template code that you are using and I'll try to see if I can elicit the said problem on my machine.
Previous 1, 2, 3, 4, 5, 6 Next
59 posts Page 6 of 6