by
KK » Fri Mar 09, 2018 12:17 am
Hi,
About langs - I tried check EN.php and compare fields with CS.php but it is still nto working :/ Please, look at the attachment, where is a problem.
Please see
viewtopic.php?f=4&t=11382&p=30106#p30106About date - dropdown date is okay but better will be if I somehow change date format in list - Feb 15 2018 to 15.02.2018 - Its possible?
Yes. You'll have to upgrade to the version of Couch available currently at GitHub (v2.1b as of this post).
Once that is done, please edit your 'couch/addons/kfunctions.php' file (if this file is not found, rename kfunctions.example.php to this name) and paste the following code in it -
- Code: Select all
class MyOverrides{
static function override_renderables(){
global $FUNCS;
$FUNCS->override_render( 'list_date', array('renderable'=>'MyOverrides::_render_list_date') );
$FUNCS->override_render( 'list_mod_date', array('renderable'=>'MyOverrides::_render_list_mod_date') );
}
static function _render_list_date(){
global $CTX, $FUNCS;
$publish_date = $CTX->get( 'k_page_date' );
if( $publish_date != '0000-00-00 00:00:00' ){
$html = $FUNCS->date( $publish_date, "M jS Y" );
}
else{
$html = '<span class="label label-error">'.$FUNCS->t('unpublished').'</span>';
}
return $html;
}
static function _render_list_mod_date(){
global $CTX, $FUNCS;
$mod_date = $CTX->get( 'modification_date' );
$html = $FUNCS->date( $mod_date, "M jS Y @ H:i" );
return $html;
}
}
$FUNCS->add_event_listener( 'override_renderables', array('MyOverrides', 'override_renderables') );
The code above is overriding the core functions inside Couch which are outputting the dates in admin listing pages (there are actually two formats of dates used - one for normal pages and the other used in 'Drafts' listing).
You won't, however, see any difference just yet in the admin-panel because the code above is actually exactly duplicating the format logic used by Couch core. It does give you a single place where you can change the date formats easily and safely.
To do that, edit these two lines in the code we pasted above -
- Code: Select all
$html = $FUNCS->date( $publish_date, "M jS Y" );
- Code: Select all
$html = $FUNCS->date( $mod_date, "M jS Y @ H:i" );
and change the "M jS Y" and "M jS Y @ H:i" strings to whatever format you desire.
The details of that format is found at -
http://docs.couchcms.com/tags-reference/date.htmlFor example, I changed the format to -
- Code: Select all
$html = $FUNCS->date( $publish_date, "d.m.Y" );
- Code: Select all
$html = $FUNCS->date( $mod_date, "d.m.Y @ H:i" );
and this is how the dates show up in my admin panel -

- Untitled-1.png (4.41 KiB) Viewed 3801 times
As you can see, instead of Feb 15 2018, its is now 15.02.2018 which you wanted.
Hope it helps.