Re: [SMARTY] Basic question about insert
| From: | messju mohr | Date: | Thu, 17 Jul 2003 08:58:56 +0000 |
| Subject: | Re: [SMARTY] Basic question about insert | ||
| References: | 1 2 3 4 5 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9916@lists.php.net to get a copy of this message | ||
On Thu, Jul 17, 2003 at 09:46:45AM +0200, Luc Saint-Elie wrote:
> Heelo messju,
>
> Another question about insert : does this work with custom functions ?
>
> For example, is it possible to use insert with Smarty Calendar Pug in (
> http://michael.yoon.org/software/smarty-plugins/)
> The calendar plug in is used like that
>
> In the .php file
>
> setlocale(LC_TIME,"fr_FR");
> if (empty($_GET['year']) || empty($_GET['month']) ||
> empty($_GET['day'])) {
>
> $today = getdate();
> $year = $today['year'];
> $month = $today['mon'];
> $day = $today['mday'];
> } else {
> $year = $_GET['year'];
> $month = $_GET['month'];
> $day = $_GET['day'];
> }
> $smarty->assign('year', $year);
> $smarty->assign('month', $month);
> $smarty->assign('day', $day);
> $smarty->assign('url_format',
> '?page=archv&year=%Y&month=%m&day=%d');
>
> In the .tpl file
>
> {calendar url_format=$url_format
> year=$year month=$month day=$day}
you mean, make "calendar" (which i don't know of) an insert function?
as i stated before: the parameters to an insert-function are cached
the same way, the page around them is cached. so you won't get the
actual $_GET-parameters passed to your calendar-function, but values
from the time, when page was written to the cache.
be creative, and write a wrapper function. maybe sth like:
function insert_calendar($params, &$smarty) {
/* overwrite cached params by the actual ones */
$params['day'] = $smarty->get_template_vars['day'];
$params['month'] = $smarty->get_template_vars['month];
$params['year'] = $smarty->get_template_vars['year'];
/* call the original function */
return smarty_function_calendar($params, $smarty);
}
this may work for you.
or did you mean something completely different?
> Thanks in advance
>
> Luc