Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Hi, i have input field for changing date on page:

Code: Select all
<cms:config_form_view>
         <cms:field 'my_publish_date' no_wrapper='1'>
         <div id="my-date-dropdown" style="margin-top: 6px; <cms:if k_page_date='0000-00-00 00:00:00' >visibility:hidden;</cms:if>">
            <cms:input
               name=k_field_input_name
               type='datetime'
               format='dmy'
               fields_separator=','
               default_time="<cms:if k_cur_form_mode='edit' && k_page_date!='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else />@current</cms:if>"
               required='1'
            />
         </div>
       </cms:field>
   </cms:config_form_view>



I can't edit date, i can only see when the page is created.

In tag default_time="<cms:if k_cur_form_mode='edit' && k_page_date!='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else />@current</cms:if>" is there option to edit this and make changes of date?

Thanks in advance.

Attachments

Hi,

The <cms:input> you are using is a plain HTML input that has no notion (unlike <cms:editable>) of persisting data anywhere.

I assume your code has been taken from the example in viewtopic.php?f=5&t=10241 where we use the datetime input to change the system-field showing the publish-date.

If you take a look at the mentioned code, you'll notice that there is also a <cms:persist> tag in there that takes the data from <cms:input> and saves it in the system publish-date. This bit is missing from your code so the changes get lost.

That said, even if you go ahead and add the missing <cms:persist> tag, the code will not work in your case - because you are using 'nested-pages' and they do not support the publish-date system field.

I am not sure how you intend to use the date field but If you simply want to save a date value for the pages, you may define a <cms:editable> region of type 'datetime' and that should suffice.

Hope this helps. Please try and let me know.
Thanks. Editable region for date is working, but format for date is not working for this editable region, i tried with this:

Code: Select all
<cms:show date_edit format='%B %d, %Y'/>


Result on frontpage is like this: 2022-05-30 00:00:00


After deleting the first option of code (file is page.php) for showing the date in CMS, it's still visible. Why?

Attachments

After deleting the first option of code (file is page.php) for showing the date in CMS, it's still visible. Why?

I suppose you have removed the entire <cms:config_form_view> block.. please try placing an empty block back where it was originally located -
Code: Select all
<cms:config_form_view>

</cms:config_form_view>

Visit the template as super-admin and now the phantom field should vanish.
You may remove the empty block placed above now.

Does this help?
Yes, it's working. Thanks!

I have this in code for formating date, but it's not working:

Code: Select all
<cms:show date_edit format='%B %d, %Y'/>


Result on frontpage is like this: 2022-05-30 00:00:00

Is there something different for formating custom datetime editable?
I have this in code for formating date, but it's not working:

You are using "Locale-aware format characters" (these contain the % sign) - as mentioned in the docs (https://docs.couchcms.com/tags-reference/date.html), you'll need to specify a proper 'locale' for the feature to work e.g. -
Code: Select all
<cms:date k_page_date format='%B %d, %Y' locale='french' />

The specified 'locale' also needs to be available on your server else the default 'english' would be used;
You can have further details from the mentioned link.

Hope this helps.
KK wrote:
I have this in code for formating date, but it's not working:

You are using "Locale-aware format characters" (these contain the % sign) - as mentioned in the docs (https://docs.couchcms.com/tags-reference/date.html), you'll need to specify a proper 'locale' for the feature to work e.g. -
Code: Select all
<cms:date k_page_date format='%B %d, %Y' locale='french' />

The specified 'locale' also needs to be available on your server else the default 'english' would be used;
You can have further details from the mentioned link.

Hope this helps.


I made solution with jQuery because server is using default 'english'. Thanks anyway KK for help!
If anyone stumbles upon this topic, for the first problem there is a tweak that takes care of the config_xxxx_view updates automatically. Visit Tweakus-Dilectus » clean-up-template-configs for install details.

The second problem, look at my another page that has more examples Midware Tags Reference » date with locales and charsets.
8 posts Page 1 of 1