Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
58 posts Page 4 of 6
Previous 1, 2, 3, 4, 5, 6 Next
Is there a way to only show the time picker?
Something like: allow_date='0' (which does not work obviously)

thanks
Korneel Eeckhout
Hello Korneel :)

Is there a way to only show the time picker?
I'm afraid not. For now, the date part is mandatory.
I'm afraid not. For now, the date part is mandatory.


I suspected as much, thanks anyway.
KK wrote: Beginning with v1.4RC, Couch ships with a native 'datetime' editable region -
Code: Select all
<cms:editable
    type='datetime'
    name='my_datetime'
    label='Date of Birth'
/> 

and an equivalent cms:input type for use with front-end forms -
Code: Select all
<cms:input 
    type='datetime'
    name='my_datetime'
/>

0.png


IMP:
The 'datetime' type comes bundled in with the 'data-bound form' addon (which, by default, comes disabled).
So, you'll need to enable the 'data-bound form' addon first for the 'datetime' to be available.

The process is the same as for all addons -
1. In the 'couch/addons' folder, you'll find 'kfunctions.example.php'.
Please rename it to make it 'kfunctions.php'
(if you have an older installation that has been upgraded to 1.4, you'll already have 'kfunctions.php' so this step can be skipped).

2. Finally, open kfunctions.php in a text editor and remove the comments (i.e. '//') from the following line in it (or put in the line if not present on an older installation) to make it -
Code: Select all
require_once( K_COUCH_DIR.'addons/data-bound-form/data-bound-form.php' );

That will enable data-bound form as well as the datetime region.


TIP:
While using this type on the front-end (either as plain cms:input or as 'bound' fields), you might find linking to the CSS used by it in the admin-panel useful -
Code: Select all
<link rel="stylesheet" href="<cms:show k_admin_link />addons/data-bound-form/datetime.css" type="text/css" media="screen" />

Of course, you are free to use your own style instead.

Parameters:
In addition to the parameters common to all editable regions (e.g. required, validator etc.), this new type supports the following parameters that can be used to tweak its appearance and behaviour -

format
Defines the order of the inputs representing 'year', 'month' and 'day'.
Acceptable values are 'dmy', 'ymd' or 'mdy'.
If none of the above are specified, the default value of 'mdy' is used.

fields_separator
Defines the character used to separate the 'year', 'month' and 'day' inputs.
Acceptable values are '/', '.' or '-'.
If none of the above are specified, the default value of '/' is used.

months
Can be used to define the names shown in the 'months' dropdown.
Acceptable string needs to have 12 comma-separated month-names e.g.
Code: Select all
<cms:editable
    type='datetime'
    name='my_datetime'
    label='Date of Birth'
    months='janvier, février, mars, avril, mai, juin, juillet, août, septembre, octobre, novembre, décembre'
/> 

If not specified, the default 'Jan', 'Feb' sequence is used.

allow_time
Can be used to allow input of time also by setting it to '1'.
1.png

The default value is '0' i.e. the inputs for time values are not shown.

am_pm
If the 'allow_time' parameter is set to '1', this parameter can be used to set if the 'hours' are showm in '24hrs' or the '12hrs am-pm' format.
The default value is '0' i.e. by default the '24 hrs' format is used.

default_time
Can be used to set the date/time displayed by default.
Valid values are
a. A blank
b. A string in the 'yyyy-mm-dd' or 'yyyy-mm-dd hh:mm:ss' format ( e.g. '2008-05-14' or '2008-05-14 02:08:45')
c. The special string '@current'. This will always display the current date/time.

minute_steps
If the 'allow_time' parameter is set to '1', this parameter can be used to set the interval between the values displayed in 'minutes' dropdown.
The default value is '10' i.e. the 'minutes' dropdown shows - 00, 10, 20, 30, 40, 50

show_labels
By default, the constituent inputs within the datepicker have a label below them showing their type e.g. 'YYYY', 'MM', 'DD' etc.
Setting this parameter to '0' will hide these labels.

This new native type can be used as an alternative to the datepicker discussed in the current thread.

Hope this helps.


Is it possible to only have one field with popup calender to select date? And if yes, can you guid me in the right direction! Thanks
Is it possible to only have one field with popup calender to select date?
The "original message" in the very first post of this thread does just that -
viewtopic.php?p=9537#p9537

Hope it helps.
Does this still work with 2.0 or is there a better way to get a date picker popup with 2.0 new features?

Thanks!
@Blutbaden,
All the old methods discussed above should work exactly the same in v2.0. It offers nothing new in this regard, I'm afraid.
KK wrote: @Blutbaden,
All the old methods discussed above should work exactly the same in v2.0. It offers nothing new in this regard, I'm afraid.


Ok, it's not working for me, must have did something wrong.

I will go back and triple check, try again and post if I need to have my stupidity fixed later. Thanks!
@Blutbaden, my apologies but my last response wasn't quite accurate when I claimed *all* the old methods will work with v2.0.

I actually only had the type 'datetime' editable region in mind (which does work exactly the same way in v2.0 as with previous versions). You, I think, had the 'popup' version in mind.

That code given the first post of this thread uses MooTools library (which is what the older versions of Couch used). Version 2.0 has now switched to using jQuery so, I am sorry, the original code won't run on it without modifications.

The same would also affect the 'colorpicker' authored by @cheesypoof.
Perhaps he'll be able to find some time and revise these two for jQuery?
I think the ideal approach going forward is to incorporate a date/time picker by default into the datetime editable region, which can be optionally disabled with a parameter. Then the question arises, should this also be done for the publish date section of advanced settings?

I'm not certain I want to tackle these issues however until 2.0 is finalized.
Previous 1, 2, 3, 4, 5, 6 Next
58 posts Page 4 of 6