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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
User avatar
amin30b
Forum Members
Forum Members
Posts: 146
Joined: Sat Mar 31, 2007 8:02 am

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

Post 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 .
Last edited by amin30b on Mon Aug 27, 2007 6:29 am, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
amin30b
Forum Members
Forum Members
Posts: 146
Joined: Sat Mar 31, 2007 8:02 am

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

Post 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 ?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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.
Last edited by calguy1000 on Sun Aug 26, 2007 7:22 pm, edited 1 time in total.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
amin30b
Forum Members
Forum Members
Posts: 146
Joined: Sat Mar 31, 2007 8:02 am

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

Post 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
User avatar
amin30b
Forum Members
Forum Members
Posts: 146
Joined: Sat Mar 31, 2007 8:02 am

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

Post 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 ? :-\
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post by calguy1000 »

use jdate_format not jdate_modifier....
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “CMSMS Core”