|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
MisYu Smarty Rookie
Joined: 12 Sep 2004 Posts: 16
|
Posted: Fri Nov 12, 2004 5:15 pm Post subject: html_options and selects |
|
|
Hello people,
While using smarty almost for the whole day at the work, you sometimes get weird ideas on how to improve this tiny, cutie and very useful stuff you guys have brought to all of us
So, what I've noticed and what I'd love to have is:
1.
Ability to change the variable name (not only the prefix!) in date and time selects.
2.
'selected' attribute in date and time selects.
3.
Ability to set the select field disabled or/and readonly in html_options/datetime selects.
4.
Modifiers on labels, so I can type something like that: {#mylabel|truncate:10#}. Yes, I can use (assuming) {$smarty.config.mylabel|truncate:10}, but... hey
5.
Ability to add javascript (in example: onselect/onclick/onchange behavior + submit) in html_options/date or time selects.
6.
An option to add n-languages to month list in date select. Languages could go into smarty.config obviously.
7.
Timerange. Okay, we all can code and we all can do it for ourselves with manually written inputs or two of date_selects combined, but if you're making an auto code for popups, mails and selects at all, the simple selection of timerange (time from - time to) could be a good idea as well.
No more thoughts.
However, smarty rocks badly and you guys are great |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Nov 12, 2004 5:25 pm Post subject: Re: html_options and selects |
|
|
MisYu wrote: |
4.
Modifiers on labels, so I can type something like that: {#mylabel|truncate:10#}. Yes, I can use (assuming) {$smarty.config.mylabel|truncate:10}, but... hey
|
You can already do {#foo#|bar:blah}
Is that what you meant? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Nov 12, 2004 5:30 pm Post subject: Re: html_options and selects |
|
|
MisYu wrote: |
5.
Ability to add javascript (in example: onselect/onclick/onchange behavior + submit) in html_options/date or time selects.
6.
An option to add n-languages to month list in date select. Languages could go into smarty.config obviously.
|
You can put your javascript on a select dropdown like so:
<select name=foo onclick="foobar();">
{html_options options=$myopts selected=$foo}
</select>
The month names in the date dropdowns are generated by strftime() to they should already be locale-aware. |
|
Back to top |
|
MisYu Smarty Rookie
Joined: 12 Sep 2004 Posts: 16
|
Posted: Fri Nov 12, 2004 6:22 pm Post subject: |
|
|
Yes, modifiers on config vars is what I meant, I've just misplaced hash, when trying to work around it, so I got syntax error.
Talking about month naming. Well, allright, however, currently we're making a system at work, that you have some date_selects for various issues. Also, everywhere you're able to change the language of the system. Ergo, the local awarness isn't something what I had on mind, because I can, in example, live in London and apart from that switch the language to German to polish my language skills. It would be cutie if we were able to do anything with the stuff that goes to time/date selects, what we want (so, not only the month naming, but also the naming of the vars).
Another thing, of which I couldn't sleep. We have got a cutie popup function. It would be great, if with it I would be able to init any file inside the popup, that I want to be inited. Currently I'm making it in a raw way:
<a href="javascript:myfunc('myfile.php?params',100,200);">foobar</a>
inside the myfile.php I'm supposed to set: $smarty->display('popup.tpl');
to view a template that I want to be popuped and to load inside anything I'd like. Would it be possible to init it *WITHOUT* php/javascript, with all variables being passed?
At the moment the steps are:
- javascripts summons the popup
- php loads smarty template inside it
- smarty does the evile work I want to
I'd like to change it to something much more familiar:
- smarty summons the popup
- inside the popup, I can use smarty and do the majik
In example:
<a href="#" {popup load="mywindow.tpl" sendvars=true winwidth=640 winheight=480}>summon!</a>
By clicking the link, smarty makes the popup window, loads a desired template inside and passes all variables from parent template. All in all, I'm getting a popup, without an external php I'm loading into it what I want, and I can use smarty inside it.
Thanks, mohrt, for your answer. Much appreciated
And excuse me for bothering and disturbing, I'm just trying to be... smarter |
|
Back to top |
|
dthought Smarty Regular
Joined: 21 Apr 2003 Posts: 55 Location: Melbourne, Australia
|
Posted: Mon Dec 13, 2004 4:47 am Post subject: |
|
|
MisYu wrote: | In example:
<a href="#" {popup load="mywindow.tpl" sendvars=true winwidth=640 winheight=480}>summon!</a>
By clicking the link, smarty makes the popup window, loads a desired template inside and passes all variables from parent template. All in all, I'm getting a popup, without an external php I'm loading into it what I want, and I can use smarty inside it.
|
Smarty inherently relies on PHP... so you have to call a PHP file first. You can't open a Smarty file inside your web browser... well, you could, but it would be parsed as straight HTML.
There are ways to solve your dilemma... the easiest and most insecure is to have a variable that straight out includes a file - eg. ?myfile=somefile.tpl - however, this trusts the users not to be naughty with the URL - a bad move.
Something better would be... hmm...
$lookup_array = array('mypage' => array('template' => 'mytemplate.tpl', 'include_file' => 'myvariables.php');
and then use ?show=mypage
and in PHP read the stuff from $lookup_array[$show]
...that's probably the easiest way. Otherwise you're asking Smarty to dynamically write a PHP file - a bit crazy |
|
Back to top |
|
|
|
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
|
|