Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi all,
i'm trying to figure out how to pre-populate feilds in a mosaic with the current data & time & user when the tile is created.
currently have:
Code: Select all
    <!-- NOTES -->
    <cms:set nice_edit_btns='bold,italic,underline,left,center,right,justify,ol,ul,removeformat,indent,outdent,link,unlink,forecolor,bgcolor,image' />
    <cms:editable name='grp_notes' label='Notes' type='group'/>
    <cms:mosaic name='notes' label='&nbsp;' group='grp_notes'>
        <cms:tile name='text' label='Note'>
            <cms:config_list_view>
                <cms:field 'k_content' >
                    <div class="mosaic-list">
                        <div class="row">
                            <div class="mos_item mos_item--note_date"><cms:show note_date />,&nbsp;</div><!--
                         --><div class="mos_item mos_item--note_time"><cms:show note_time />,&nbsp;</div><!--
                         --><div class="mos_item mos_item--note_auth"><cms:show note_auth /></div><!--
                         --><div class="mos_item mos_item--note_text"><cms:show note_text /></div>
                        </div>
                    </div>

                </cms:field>
            </cms:config_list_view>
            <cms:editable name='note_date' type='text' label='created on' width='140' ><cms:date k_page_modification_date gmt='1'/></cms:editable>
            <cms:editable name='note_time' type='text' label='at'         width='80'  ><cms:date k_page_modification_date gmt='1' format='%X'/></cms:editable>
            <cms:editable name='note_auth' type='text' label='by'         width='140' ><cms:show k_user_name /></cms:editable>
            <cms:editable name='note_text' type='nicedit' label='note'    height='600' maxheight='900' buttons="<cms:show nice_edit_btns />" ><cms:dump_all /></cms:editable>
        </cms:tile>
    </cms:mosaic>


Obviously this just pulls in the date/time the page was last saved and the user who saved it.
What I need is the data, time & user when the '+ Note' add tile button is clicked.
Have tried to see if dyanamic option could be used, but can't see what to make dynamic for a text box.

Any pointers would be greatly appreciated,
thanks,
gwil
Would those values be immutable i.e. cannot be edited by the user once the tile is created?
Please let me know.
Hi KK,
Yes, in this case they would be. Though I can imagine scenarios where mutable would be useful.
Ok. As a solution we can use the technique described in the original v2.0 post (viewtopic.php?f=5&t=10241) where we use two normal <cms:input>s to simulate the system 'publish date' field.

For our use-case, we'll hide our <cms:editable> regions and, in their place, we'll put in two <cms:input> (as these, in contrast to the editable regions. lend themselves to be made dynamic). When the form is posted, we push the values of these inputs into the editable regions.

Here is the working code -
Code: Select all
<cms:mosaic name='notes' label='&nbsp;' group='grp_notes'>
    <cms:tile name='text' label='Note'>
        <cms:config_list_view>
            <cms:field 'k_content' >
                <div class="mosaic-list">
                    <div class="row">
                        <div class="mos_item mos_item--note_date">Created on <cms:date note_date gmt='1' />&nbsp; at <cms:date note_date gmt='1' format='%X'/> By <cms:show note_auth /></div>
                        <div class="mos_item mos_item--note_text"><cms:show note_text /></div>
                    </div>
                </div>

            </cms:field>
        </cms:config_list_view>
        <cms:editable name='note_date' type='text' label='created on' width='140' />
        <cms:editable name='note_auth' type='text' label='by'         width='140' />
        <cms:editable name='note_text' type='richtext' label='note'    height='600' maxheight='900' buttons="<cms:show nice_edit_btns />" ></cms:editable>
   
        <cms:config_form_view>
            <cms:persist
                note_date=frm_my_note_date
                note_auth=frm_my_note_auth
            />

            <cms:field 'note_date' hide='1' />
            <cms:field 'note_auth' hide='1' />

            <cms:field 'my_note_date' label='Created On'>
                <cms:input
                    name=k_field_input_name
                    type='datetime'
                    format='mdy'
                    allow_time='1'
                    minute_steps='1'
                    show_secs='1'
                    fields_separator=','
                    default_time="<cms:if k_route_name eq 'create_view'>@current<cms:else /><cms:show note_date /></cms:if>"
                    required='1'
                />
            </cms:field>
           
            <cms:field 'my_note_auth' label='By'>
                <cms:input type='text'
                    name=k_field_input_name
                    value="<cms:if k_route_name eq 'create_view'><cms:show k_user_name /><cms:else /><cms:show note_auth /></cms:if>"
                />
            </cms:field>
        </cms:config_form_view>
    </cms:tile>
</cms:mosaic>


Please note that I have made use of a single field for the date instead of using one additional field to hold the time.

To make the captured date non-editable, just hide the 'my_note_date' input.

Hope this helps.
Thakyou KK. This is perfect.
so many cool little things in there to play with, like the k_route_name.
Much appreciated.
You are welcome. I am glad I could help.
6 posts Page 1 of 1
cron