Page 1 of 1

I want to integrate my native date with default php date ;(help plz)[solved]

Posted: Sun Aug 26, 2007 6:22 pm
by amin30b
Hi
I have written an php function that convert default php date to my native date (Jalali Date);
Now I describe how it works :
this is default php function :

Code: Select all

echo date("l j F Y");
now if I include my function in any script , below function convert default php date
to my native date :

Code: Select all

echo jdate("l j F Y");
I`m not familiar with date function used in CMSMS and also I`m unaccustomed with ADODB date
and some modules are using ADODB date (as I`ve seen) .

If I use my function as a UDT , could I change default php date function as described above in modules ?
And another question : Does every module use its independent date funtion? if not do all modules
use an integrated php date structure that get it from CMSMS core(main) script ?

Please guide me to change default date to my native date with using my function .

Re: I want to integrate my native date with default php date ;(help plz)

Posted: Sun Aug 26, 2007 6:26 pm
by calguy1000
Every module uses their own date code.... However, you can use the date_format smarty modifier to modify how a date is displayed.  There should be no need to modify any php code.

You just have to go into each template (hopefully everything is in templates now)..... and wherever a date is output, use {$thedate_variable|date_format}

See this page as a reference:

Code: Select all

http://smarty.php.net/manual/en/language.modifier.date.format.php

Re: I want to integrate my native date with default php date ;(help plz)

Posted: Sun Aug 26, 2007 6:48 pm
by amin30b
Hi calguy1000
I`ve modified my first post .(you answered before modify)
And I place my main code here for download , please have a view on it :

http://www.savefile.com/files/1004979

Does my code affect on smarty date_format like example I`ve described in my first post ?
What do you think ?

Re: I want to integrate my native date with default php date ;(help plz)

Posted: Sun Aug 26, 2007 7:16 pm
by calguy1000
To use this code as it is, you would have to go through all .php files and find occurrances to date and replace them with jdate.  But you take the risk of completely messing up the behaviour of the modules and the core (they may not be able to make date comparisons properly, or query the database by date). 

It's probably not a good thing to do.

if what you want is strictly a way to convert how dates are displayed, and the date_format modifier won't do it for you, .... then your best bet would be to

a) Create a smarty modifier to do it for you
    (use lib/smarty/plugins/modifier.date_format.php as a reference)
    (place your jdate_format modifier in a file called modifier.jdate_format.php in lib/smarty/plugins)

b) modify all your templates to use {$datevariable|jdate_modifier} wherever dates are displayed. 
    You will probably need to modify some of the admin templates if you want to change the way dates are displayed in the admin as well.

Re: I want to integrate my native date with default php date ;(help plz)

Posted: Sun Aug 26, 2007 7:24 pm
by calguy1000
A quick google search for "smarty jalali" turned up this:

Code: Select all

http://www.phpinsider.com/smarty-forum/viewtopic.php?p=32917&sid=fb9d4c85be485ae5852215289648222e
it looks like part a) of my post above is already done for you.

Re: I want to integrate my native date with default php date ;(help plz)

Posted: Sun Aug 26, 2007 8:02 pm
by amin30b
calguy1000 wrote: A quick google search for "smarty jalali" turned up this:

Code: Select all

http://www.phpinsider.com/smarty-forum/viewtopic.php?p=32917&sid=fb9d4c85be485ae5852215289648222e
it looks like part a) of my post above is already done for you.
it`s interesting case  ;) I will work on it .
tnx

Re: I want to integrate my native date with default php date ;(help plz)

Posted: Sun Aug 26, 2007 10:59 pm
by amin30b
calguy1000 , I`m confused a little ;

For example in "Question" module template when I replace

Code: Select all

<h4>{$entry->created|date_format}</h4>
with:

Code: Select all

<h4>{$entry->created|jdate_format}</h4>
it shows me correct date in my native date format .

But when I replace

Code: Select all

<h4>{$entry->created|date_format}</h4>
with:

Code: Select all

<h4>{$datevariable|jdate_modifier}</h4>
I get these errors:

string(153) "Smarty error: [in module_db_tpl:Questions;summarySample line 32]: [plugin] modifier 'jdate_modifier' is not implemented (core.load_plugins.php, line 124)"
Fatal error: Call to undefined function: smarty_modifier_jdate_modifier() in c:\appserv\www\cmsms\tmp\templates_c\Questions^%%3D^3D1^3D10C67A%%module_db_tpl%3AQuestions%3BsummarySample.php on line 57
Am I wrong with somethings ? :-\

Re: I want to integrate my native date with default php date ;(help plz)

Posted: Sun Aug 26, 2007 11:05 pm
by calguy1000
use jdate_format not jdate_modifier....