Page 1 of 1

[SOLVED] CTL module Maker - Date format in backend section

Posted: Fri Jul 02, 2010 1:24 pm
by nico63
Hi,

Is it possible to display in a module created with CTL Module Maker only the Date in a field in the admin section (backend) and not both date and time ?
Is it possible also that this date appear in french format : day first, then month then years ?

Thanks for answers,
Nicolas.

Re: CTL module Maker - Date format in backend section

Posted: Fri Jul 02, 2010 2:43 pm
by klenkes
Hi Nicolas.

You have to modify adminpanel.tpl to make this work.

Like this:

Code: Select all

<tbody>
{cycle values="row2,row1" assign=rowclass reset=true}
{foreach from=$itemlist item=oneitem}
{cycle values="row2,row1" assign=rowclass}
<tr class="{$rowclass}" onmouseover="this.className='{$rowclass}hover';" onmouseout="this.className='{$rowclass}';">
{foreach from=$adminshow item=column}
{assign var=oneval value=$column[1]}

<td{if $column[2]} class="ctlmm_nosearch"{/if}>
{* ### Modification for Date ### *}
{if $oneval eq "date_created"}
{$oneitem->$oneval|cms_date_format:"%e.%m.%Y"}
{else}
{$oneitem->$oneval}
{/if}
</td>

{/foreach}
</tr>
{/foreach}
</tbody>
This is only the part and the field date_created in a format like: 02.07.2010
You can change the date format to whatever you like, just in the way it works in all the other places in CMSMS.

Bernd

Re: CTL module Maker - Date format in backend section

Posted: Fri Jul 02, 2010 3:18 pm
by nico63
Hi Bernd,

Many thanks for your answer.
I modified the file adminpanel.tpl in the part exactly as you explain, but unfortunately, it doesn't work for me ==> I still have in the backend display : Year-Month-Day + Time.
I don't understand...

I used CTLmodule Maker ver : 1.8.9.3 (the latest version) to create my module in my local computer under xampp before reporting the module in line to my website.

I will search again to resolve this problem but if you have an idea you're welcome!
Thanks again,
Nicolas.

Re: CTL module Maker - Date format in backend section

Posted: Fri Jul 02, 2010 4:15 pm
by klenkes
mhh... I can't think of a reason why this wouldn't work, except that the {if $oneval eq "date_created"} is never true.
For testing put some character(just an x) after this and see if it is printed.
If not the field may have a different name.
{$oneitem|print_r} shows you the field names.  [date_created] or something else.

Re: CTL module Maker - Date format in backend section

Posted: Fri Jul 02, 2010 6:00 pm
by nico63
Many, many thanks,

Effectively : {if $oneval eq "date_created"} was never true !
This is not the name of my field.
The name of the field to test is the name I exactly give to the field when I created the module with CTLMM.
In my case, the name was "dtdebut" (for start date, so i have to do an other test with end date...)

Many thanks again, Bernd, and also for all the community of CMSMS,
Nicolas.

Re: CTL module Maker - Date format in backend section

Posted: Fri Jul 02, 2010 10:53 pm
by nico63
More information for people which have the same problem :

1) if you don't want that the time appear in a Date/Time field in edit mode of your module, you have to remove the tag {html_select_time prefix=... } in the template of your module : editNameofLevel.tpl (replace NameofLevel by the name of the level in which you want to perform this operation).

2) still for edit mode, to select order for displaying correctly the date field, you have to modify in the smarty plugin : function.html.select.date.php (...lib/smarty/plugins) the line 77 (for my CMSMS version) like this : $field_order     = 'DMY';
(it is comment so it's simple to find this line!) and also to have the month in the language of your country : add line setlocale(LC_TIME, "French"); in the beginning of the function (replace French by the name of you language in English.

Enjoy!
Nicolas

Re: [SOLVED] CTL module Maker - Date format in backend section

Posted: Sat Jul 03, 2010 12:03 am
by nico63
Final clarification :

In my last post I write
add line setlocale(LC_TIME, "French"); in the beginning of the function (replace French by the name of you language in English
It is not necessary to do this and perhaps not recommended: on my local computer in xampp, local language setting was not configured but in my host server there is no problem to display the month with my local language.

Nicolas.