Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hello all,

I wonder if anyone can shed some light on this one for me...

I have a template 'themes_sa.php' which contains:
Code: Select all
<cms:set opt_item='fg|bg|stroke|fill' 'global' />
<cms:set opt_alpha10='10=1|20=2|30=4|40=8|50=16|60=32|70=64|80=128|90=256' 'global' />
<cms:set opt_alpha15='05=1|15=2|25=4|35=8|45=16|55=32|65=64|75=128|85=256|95=512' 'global' />
<cms:set opt_alpha33='33=1|66=2' 'global' />
<cms:set opt_alphaGM='30.9|38.2|61.8' 'global' />
<cms:template title='SUPER-ADMIN THEME' clonable='1' executable='1' order='1' parent='settings' hidden='1'>
    <cms:editable order='10000' name='grp_defaults' type='group' label='Defaults' collapsed='1'>
        <cms:editable order='1000' name="sep_defaults_1" type='message'>
            <h3>Colour selection</h3><hr/>
        </cms:editable>
        <cms:editable order='1030' name='default_for_content' label='For content'   type='checkbox' opt_values='Yes=1' />
        <cms:editable order='1040' name='default_for_all'     label='For all'       type='checkbox' opt_values='Yes=1' />
        <cms:editable order='1050' name='default_for_item'    label='For which'     type='checkbox' opt_values=opt_item />
        <cms:editable order='1060' name='default_for_alpha10' label='For alpha10'   type='checkbox' opt_values=opt_alpha10 />
        <cms:editable order='1070' name='default_for_alpha15' label='For alpha15'   type='checkbox' opt_values=opt_alpha15 />
        <cms:editable order='1080' name='default_for_alpha33' label='For alpha33'   type='checkbox' opt_values=opt_alpha33 />
        <cms:editable order='1090' name='default_for_alpha61' label='For alphaGM'   type='checkbox' opt_values=opt_alphaGM />
    </cms:editable>
    <cms:mosaic order='20000' name='content' label='CSS Blocks'>
        <!-- BREAKPOINTS -->
        <cms:tile name='tile_bps' label='Breakpoints'>
            <cms:repeatable name='rep_bps' label='breakpoints'>
                <cms:editable name='name' type='text' required='1'/>
                <cms:editable name='width' type='text' required='1'/>
            </cms:repeatable>
        </cms:tile>

        <!-- COLOURS -->
        <cms:tile name='tile_colours' label='Colours'>
            <cms:repeatable name="rep_colours" label='Colours' >
                <cms:editable order='10' name="name"        label="Suffix"        type='text' required='1' maxlength='50' />
                <cms:editable order='20' name="colour"      label="hex val"       type='text' required='1' maxlength='09' />
                <cms:editable order='30' name="for_content" label='For content'   type='checkbox' opt_values='Yes=1'     dynamic='opt_selected' opt_selected='theme/colour/get_default_content.html' />
                <cms:editable order='40' name="for_all"     label='For all'       type='checkbox' opt_values='Yes=1'     dynamic='opt_selected' opt_selected='theme/colour/get_default_all.html' />
                <cms:editable order='50' name="for_item"    label='For which'     type='checkbox' opt_values=opt_item    dynamic='opt_selected' opt_selected='theme/colour/get_default_items.html' />
                <cms:editable order='60' name="for_alpha10" label='For alpha10'   type='checkbox' opt_values=opt_alpha10 dynamic='opt_selected' opt_selected='theme/colour/get_default_alpha10.html'/>
                <cms:editable order='70' name="for_alpha15" label='For alpha15'   type='checkbox' opt_values=opt_alpha15 dynamic='opt_selected' opt_selected='theme/colour/get_default_alpha15.html'/>
                <cms:editable order='80' name="for_alpha33" label='For alpha33'   type='checkbox' opt_values=opt_alpha33 dynamic='opt_selected' opt_selected='theme/colour/get_default_alpha33.html'/>
                <cms:editable order='90' name="for_alpha61" label='For alphaGM'   type='checkbox' opt_values=opt_alphaGM dynamic='opt_selected' opt_selected='theme/colour/get_default_alpha61.html'/>
            </cms:repeatable>

        </cms:tile>

    </cms:mosaic>
</cms:template>


and various snippets for the dynamic 'opt_selected', eg. get_default_items.html
Code: Select all
<cms:get_field 'default_for_item' masterpage='themes_sa.php' >


This works perfectly well when the template is non-clonable. The default checkbox settings are used when a new row is added to the 'rep_colours' repeatable.

If I change the template to cloneable I can not for the life of me figure out how to get the current page into the snippet.
I have tried
Code: Select all
<cms:get_field 'default_for_item' masterpage='themes_sa.php' page=k_page_name>

and any variations of the above I could come up with, but no joy.

Anyone know if this is possible? If so, any clues :) ?

cheers,
gwil
Sorry, I realise i've been looking at it all wrong :|
What i'm after is the current content of the default checkbox fields themselves, not a cloned page.
Just have to figure out how to incorporate the js into the snippet...
Ok, current plan is to use js to hook onto the add-a-row button in the repeatable region in the mosaic iframe #k_admin_frm and update its checkboxes etc, with defaults read live from the underlying template form (also #k_admin_frm).
iframe might cause me a problem, but wish me luck
If I change the template to cloneable I can not for the life of me figure out how to get the current page into the snippet.

When you click 'Add' in backend, a new page doesn't yet exist - i.e. has no k_page_name saved or editables filled and saved to db. So, it will help if you move defaults to cms:globals which will be available for each page, even not saved one.
This works perfectly well when the template is non-clonable.
- that's because a non-clonable template internally is a clonable template, only with a single master/default page - so values are there once you visited and saved it for the first time
@trendoman, hi again and once more thanks for your time.
yes i realised this after losing myself down another rabbit hole.
also, had got it into my head that the defaults needed to be per theme, rather than per site.
so, yes, now i see that globals is the way to go,
must learn to walk away from the screen more.
cheers,
gwil
You are welcome!
Could you share screenshots of the result (theme look)?
will post some shots soon.
just going step by step :)
had to get autoprefixing working for generated css so modified @tim's minify tag to allow possibility of using css-crush.php (see https://www.couchcms.com/forum/viewtopic.php?f=8&t=11090&p=34087#p34087).
7 posts Page 1 of 1