Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

html_select_date (selected date feature hack)
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
tavancini
Smarty Rookie


Joined: 22 Apr 2003
Posts: 5
Location: Brazil

PostPosted: Tue Apr 22, 2003 2:23 pm    Post subject: html_select_date (selected date feature hack) Reply with quote

hi,

i did a simple hack in the html_select_date plugin that you can select a specific date, instead of the actual date, using a timestamp as a parameter.

if anyone want the hack, reply me.
or, if the smarty project like this feature, i will be really happy to help. : )

thanks!
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Apr 22, 2003 7:34 pm    Post subject: Reply with quote

No hack needed, use the time attribute.
Back to top
View user's profile Send private message Visit poster's website
tavancini
Smarty Rookie


Joined: 22 Apr 2003
Posts: 5
Location: Brazil

PostPosted: Tue Apr 22, 2003 7:51 pm    Post subject: whooooo... Reply with quote

no comments.

b000! Rolling Eyes Rolling Eyes Rolling Eyes
Back to top
View user's profile Send private message
ilir
Smarty Rookie


Joined: 20 Apr 2003
Posts: 16
Location: NYC

PostPosted: Fri Apr 25, 2003 1:17 pm    Post subject: Reply with quote

Mhort,

I read that in the Doc, too, but how would I use $time to get a selection for Month/Day (Year optional) 14 days from today???

Thanks,

Ilir.
_________________
The real problem is not whether machines think but whether men do.
- B. F. Skinner
Back to top
View user's profile Send private message MSN Messenger
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Apr 25, 2003 2:36 pm    Post subject: Reply with quote

{html_select_date time="+14 days"}

This isn't a Smarty-specific syntax btw, this takes anything parsible by strftime(), so see the PHP documentation for the details.
Back to top
View user's profile Send private message Visit poster's website
machnhed1
Smarty Regular


Joined: 21 Apr 2003
Posts: 39
Location: Illinois

PostPosted: Wed May 19, 2004 7:49 pm    Post subject: Reply with quote

mohrt wrote:
{html_select_date time="+14 days"}

This was a very useful post. Thank you. Very Happy
_________________
"Every operating system out there is about equal in the number of vulnerabilities reported. We all suck."

- Microsoft Senior Vice President Brian Valentine
Back to top
View user's profile Send private message
machnhed1
Smarty Regular


Joined: 21 Apr 2003
Posts: 39
Location: Illinois

PostPosted: Thu Aug 19, 2004 3:32 pm    Post subject: Reply with quote

mohrt wrote:
{html_select_date time="+14 days"}

This isn't a Smarty-specific syntax btw, this takes anything parsible by strftime(), so see the PHP documentation for the details.


Is there any way to do this for the date command?

For example:
Code:
{$smarty.now|date_format:"%m" time="-30 days"}


Or do I have to pass this value from the php file?
_________________
"Every operating system out there is about equal in the number of vulnerabilities reported. We all suck."

- Microsoft Senior Vice President Brian Valentine
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Aug 19, 2004 3:36 pm    Post subject: Reply with quote

{"-30 days"|strtotime|date_format:"%m"}
Back to top
View user's profile Send private message Visit poster's website
machnhed1
Smarty Regular


Joined: 21 Apr 2003
Posts: 39
Location: Illinois

PostPosted: Thu Aug 19, 2004 3:45 pm    Post subject: Reply with quote

mohrt,

Big thanks again, this was EXACTLY what I needed. Is there documentation that I am missing that explains how this is possible? Perhaps via PHP.net or something Question
_________________
"Every operating system out there is about equal in the number of vulnerabilities reported. We all suck."

- Microsoft Senior Vice President Brian Valentine
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Aug 19, 2004 4:19 pm    Post subject: Reply with quote

http://php.net/strtotime
Back to top
View user's profile Send private message Send e-mail Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Aug 19, 2004 4:59 pm    Post subject: Reply with quote

BTW: {"-30 days"|date_format:"%m"} should be enough. since date_format uses strtotime internally to convert "-30 days" to a timestamp.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Aug 19, 2004 6:28 pm    Post subject: Reply with quote

messju wrote:
BTW: {"-30 days"|date_format:"%m"} should be enough. since date_format uses strtotime internally to convert "-30 days" to a timestamp.


Good catch, that is true.
Back to top
View user's profile Send private message Visit poster's website
machnhed1
Smarty Regular


Joined: 21 Apr 2003
Posts: 39
Location: Illinois

PostPosted: Thu Aug 19, 2004 6:37 pm    Post subject: Reply with quote

messju wrote:
BTW: {"-30 days"|date_format:"%m"} should be enough. since date_format uses strtotime internally to convert "-30 days" to a timestamp.


Indeed they both worked. Thanks to each of you; your're real assets to this forum.
_________________
"Every operating system out there is about equal in the number of vulnerabilities reported. We all suck."

- Microsoft Senior Vice President Brian Valentine
Back to top
View user's profile Send private message
novus
Smarty Rookie


Joined: 17 Nov 2003
Posts: 7

PostPosted: Tue Dec 28, 2004 3:53 pm    Post subject: Reply with quote

hi

the posts above were very useful but now i have another problem. i want to select the year 4 years ago. i did it with

{html_select_date prefix="dateFrom" time="-4 years" start_year="-4" display_days=false}

but this code wont work.

any idea?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Dec 28, 2004 3:58 pm    Post subject: Reply with quote

only the time attribute respects strtotime(), othewise you have to do it manually (or assign $start_year from PHP)

Code:
{html_select_date prefix="dateFrom" time="-4 years" start_year="-4 years"|date_format:"%Y" display_days=false}
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP