PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.smarty.general > Plugin problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Plugin problem

Réponse
 
LinkBack Outils de la discussion
Vieux 03/11/2006, 15h03   #1
Erich C. Beyrent
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Plugin problem

I have written a plugin called html_select_date2, and it is giving me
some trouble. The first time the page loads, the function is called and
everything works smashingly. However, if I refresh the page, I get this:
*
Fatal error*: Call to undefined function:
smarty_function_html_select_date2() in
*/public_html/php/templates_c/%%24^24D^24D5865F%%default.form.tpl.php*
on line *97

*Is this a permissions problem, or is something else going on here?

-Erich-
  Réponse avec citation
Vieux 03/11/2006, 15h09   #2
Jochem Maas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

Erich C. Beyrent wrote:
> I have written a plugin called html_select_date2, and it is giving me
> some trouble. The first time the page loads, the function is called and
> everything works smashingly. However, if I refresh the page, I get this:
> *
> Fatal error*: Call to undefined function:
> smarty_function_html_select_date2() in
> */public_html/php/templates_c/%%24^24D^24D5865F%%default.form.tpl.php*
> on line *97
>
> *Is this a permissions problem, or is something else going on here?


the function is not being loaded. what I do is stick all my custom
smarty plugins in a directory and then add that directory to the list of
plugin dirs - that way Smarty will always be able to find/load your plugins

>
> -Erich-
>

  Réponse avec citation
Vieux 03/11/2006, 15h15   #3
Erich C. Beyrent
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

Jochem Maas wrote:
> Erich C. Beyrent wrote:
>
>> I have written a plugin called html_select_date2, and it is giving me
>> some trouble. The first time the page loads, the function is called and
>> everything works smashingly. However, if I refresh the page, I get this:
>> *
>> Fatal error*: Call to undefined function:
>> smarty_function_html_select_date2() in
>> */public_html/php/templates_c/%%24^24D^24D5865F%%default.form.tpl.php*
>> on line *97
>>
>> *Is this a permissions problem, or is something else going on here?
>>

>
> the function is not being loaded. what I do is stick all my custom
> smarty plugins in a directory and then add that directory to the list of
> plugin dirs - that way Smarty will always be able to find/load your plugins
>
>

LOL

In the Why Use Smarty page, it says:

"Adding custom features to Smarty is as easy as dropping them in the
plugin directory and mentioning them in the template."

So that's exactly what I did. What I don't understand is why the plugin
works fine the first time the page loads, but fails when you refresh the
browser. Why does it get loaded the first time, but not from the
compiled template?

-Erich-
  Réponse avec citation
Vieux 03/11/2006, 16h23   #4
Erich C. Beyrent
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

That's how it appears to me, but I'm not sure why that is happening, or
how to fix it.

-Erich-

Dean Ariel wrote:
> Maybe it's not including the plugins when it's compiled ??
>
> Dean
>
> On 11/3/06, Erich C. Beyrent <erich.beyrent@beyrent.net> wrote:
>> Jochem Maas wrote:
>> > Erich C. Beyrent wrote:
>> >
>> >> I have written a plugin called html_select_date2, and it is giving me
>> >> some trouble. The first time the page loads, the function is

>> called and
>> >> everything works smashingly. However, if I refresh the page, I

>> get this:
>> >> *
>> >> Fatal error*: Call to undefined function:
>> >> smarty_function_html_select_date2() in
>> >>

>> */public_html/php/templates_c/%%24^24D^24D5865F%%default.form.tpl.php*
>> >> on line *97
>> >>
>> >> *Is this a permissions problem, or is something else going on here?
>> >>
>> >
>> > the function is not being loaded. what I do is stick all my custom
>> > smarty plugins in a directory and then add that directory to the

>> list of
>> > plugin dirs - that way Smarty will always be able to find/load your

>> plugins
>> >
>> >

>> LOL
>>
>> In the Why Use Smarty page, it says:
>>
>> "Adding custom features to Smarty is as easy as dropping them in the
>> plugin directory and mentioning them in the template."
>>
>> So that's exactly what I did. What I don't understand is why the plugin
>> works fine the first time the page loads, but fails when you refresh the
>> browser. Why does it get loaded the first time, but not from the
>> compiled template?
>>
>> -Erich-
>>
>> --
>> Smarty General Mailing List (http://smarty.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>

>
>

  Réponse avec citation
Vieux 03/11/2006, 16h38   #5
Monte Ohrt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

What is the name of the plugin file, and what is the content? Do you
have one plugin directory, or multiple?

Erich C. Beyrent wrote:
> That's how it appears to me, but I'm not sure why that is happening,
> or how to fix it.
>
> -Erich-
>
> Dean Ariel wrote:
>> Maybe it's not including the plugins when it's compiled ??
>>
>> Dean
>>
>> On 11/3/06, Erich C. Beyrent <erich.beyrent@beyrent.net> wrote:
>>> Jochem Maas wrote:
>>> > Erich C. Beyrent wrote:
>>> >
>>> >> I have written a plugin called html_select_date2, and it is
>>> giving me
>>> >> some trouble. The first time the page loads, the function is
>>> called and
>>> >> everything works smashingly. However, if I refresh the page, I
>>> get this:
>>> >> *
>>> >> Fatal error*: Call to undefined function:
>>> >> smarty_function_html_select_date2() in
>>> >>
>>> */public_html/php/templates_c/%%24^24D^24D5865F%%default.form.tpl.php*
>>> >> on line *97
>>> >>
>>> >> *Is this a permissions problem, or is something else going on here?
>>> >>
>>> >
>>> > the function is not being loaded. what I do is stick all my custom
>>> > smarty plugins in a directory and then add that directory to the
>>> list of
>>> > plugin dirs - that way Smarty will always be able to find/load
>>> your plugins
>>> >
>>> >
>>> LOL
>>>
>>> In the Why Use Smarty page, it says:
>>>
>>> "Adding custom features to Smarty is as easy as dropping them in the
>>> plugin directory and mentioning them in the template."
>>>
>>> So that's exactly what I did. What I don't understand is why the
>>> plugin
>>> works fine the first time the page loads, but fails when you refresh
>>> the
>>> browser. Why does it get loaded the first time, but not from the
>>> compiled template?
>>>
>>> -Erich-
>>>
>>> --
>>> Smarty General Mailing List (http://smarty.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>

>>
>>

>

  Réponse avec citation
Vieux 03/11/2006, 16h48   #6
Erich C. Beyrent
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

Before I get into specifics, I should point out that I tested this
problem using the standard html_select_date plugin, and saw the exact
same behavior, so I don't think the problem is my plugin itself. I
believe there is some kind of issue with my environment.

I have a single plugin directory, which is the main
{smarty_dir}/libs/plugins directory.
The name of the plugin file is function.html_select_date2.php, which is
based upon the original html_select_date function. My modded file
allows me to override the names of the fields like this:

{html_select_date2 field_name="FromMonth,FromDay,FromYear"
day_extra="id=FromDay class=dateSelect" month_extra="id=FromMonth
class=dateSelect" year_extra="id=FromYear class=dateSelect" end_year="+2"}

The contents are as follows (this is gonna be long...):

function smarty_function_html_select_date2($params, &$smarty)
{
require_once $smarty->_get_plugin_filepath('shared','make_timestamp') ;
require_once $smarty->_get_plugin_filepath('function','html_options') ;
/* Default values. */
$prefix = "Date_";
$start_year = strftime("%Y");
$end_year = $start_year;
$display_days = true;
$display_months = true;
$display_years = true;
$month_format = "%B";
/* Write months as numbers by default GL */
$month_value_format = "%m";
$day_format = "%02d";
/* Write day values using this format MB */
$day_value_format = "%d";
$year_as_text = false;
/* Display years in reverse order? Ie. 2000,1999,.... */
$reverse_years = false;
/* Should the select boxes be part of an array when returned from PHP?
e.g. setting it to "birthday", would create "birthday[Day]",
"birthday[Month]" & "birthday[Year]". Can be combined with prefix */
$field_array = null;
/* <select size>'s of the different <select> tags.
If not set, uses default dropdown. */
$day_size = null;
$month_size = null;
$year_size = null;
/* Unparsed attributes common to *ALL* the <select>/<input> tags.
An example might be in the template: all_extra ='class ="foo"'. */
$all_extra = null;
/* Separate attributes for the tags. */
$day_extra = null;
$month_extra = null;
$year_extra = null;
/* Field name (if provided, replaces 'Day','Month', or 'Year') */
$field_name = null;
/* Order in which to display the fields.
"D" -> day, "M" -> month, "Y" -> year. */
$field_order = 'MDY';
/* String printed between the different fields. */
$field_separator = "\n";
$time = time();
$all_empty = null;
$day_empty = null;
$month_empty = null;
$year_empty = null;

foreach ($params as $_key=>$_value) {
switch ($_key) {
case 'prefix':
case 'time':
case 'start_year':
case 'end_year':
$$_key = (string)$_value;
break;
case 'month_format':
case 'day_format':
case 'day_value_format':
case 'field_array':
case 'day_size':
case 'month_size':
case 'year_size':
case 'all_extra':
case 'day_extra':
$$_key = (string)$_value;
break;
case 'month_extra':
$$_key = (string)$_value;
break;
case 'year_extra':
$$_key = (string)$_value;
break;
case 'field_name':
$arrFields = explode(',', $_value);

if($strMonthFieldName == '')
{
$strMonthFieldName = $arrFields[0];
}

if($strDayFieldName == '')
{
$strDayFieldName = $arrFields[1];
}

if($strYearFieldName == '')
{
$strYearFieldName = $arrFields[2];
}
break;
case 'field_order':
case 'field_separator':
case 'month_value_format':
case 'month_empty':
case 'day_empty':
case 'year_empty':
$$_key = (string)$_value;
break;

case 'all_empty':
$$_key = (string)$_value;
$day_empty = $month_empty = $year_empty = $all_empty;
break;

case 'display_days':
case 'display_months':
case 'display_years':
case 'year_as_text':
case 'reverse_years':
$$_key = (bool)$_value;
break;

default:
$smarty->trigger_error("[html_select_date] unknown
parameter $_key", E_USER_WARNING);

}
}

if(preg_match('!^-\d+$!',$time)) {
// negative timestamp, use date()
$time = date('Y-m-d',$time);
}
// If $time is not in format yyyy-mm-dd
if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) {
// use smarty_make_timestamp to get an unix timestamp and
// strftime to make yyyy-mm-dd
$time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
}
// Now split this in pieces, which later can be used to set the select
$time = explode("-", $time);

// make syntax "+N" or "-N" work with start_year and end_year
if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
if ($match[1] == '+') {
$end_year = strftime('%Y') + $match[2];
} else {
$end_year = strftime('%Y') - $match[2];
}
}
if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) {
if ($match[1] == '+') {
$start_year = strftime('%Y') + $match[2];
} else {
$start_year = strftime('%Y') - $match[2];
}
}
if (strlen($time[0]) > 0) {
if ($start_year > $time[0] && !isset($params['start_year'])) {
// force start year to include given date if not explicitly set
$start_year = $time[0];
}
if($end_year < $time[0] && !isset($params['end_year'])) {
// force end year to include given date if not explicitly set
$end_year = $time[0];
}
}

$field_order = strtoupper($field_order);

$html_result = $month_result = $day_result = $year_result = "";

if ($display_months)
{
$month_names = array();
$month_values = array();

if(isset($month_empty))
{
$month_names[''] = $month_empty;
$month_values[''] = '';
}

for ($i = 1; $i <= 12; $i++)
{
$month_names[$i] = strftime($month_format, mktime(0, 0, 0,
$i, 1, 2000));
$month_values[$i] = strftime($month_value_format, mktime(0,
0, 0, $i, 1, 2000));
}

$month_result .= '<select name=';

if (null !== $field_array)
{
$month_result .= '"' . $field_array . '[';
$month_result .= (null !== $strMonthFieldName) ?
$strMonthFieldName.']"' : $prefix.'Month]"';

$month_result .= ' id="'.$field_array . '[';
$month_result .= (null !== $strMonthFieldName) ?
$strMonthFieldName.']"' : $prefix.'Month]"';
}
else
{
$month_result .= (null !== $strMonthFieldName) ?
'"'.$strMonthFieldName.'"' : '"'.$prefix.'Month"';
//$month_result .= ' id="'.$strMonthFieldName.'"';
}

if (null !== $month_size)
{
$month_result .= ' size="' . $month_size . '"';
}

if (null !== $month_extra)
{
$month_result .= ' ' . $month_extra;
}

if (null !== $all_extra)
{
$month_result .= ' ' . $all_extra;
}
$month_result .= '>'."\n";

$month_result .= smarty_function_html_options(array('output'
=> $month_names,
'values'
=> $month_values,
'selected'
=> $a=$time[1] ? strftime($month_value_format, mktime(0, 0, 0,
(int)$time[1], 1, 2000)) : '',

'print_result' => false),
$smarty);
$month_result .= '</select>';
}

if ($display_days)
{
$days = array();
if (isset($day_empty))
{
$days[''] = $day_empty;
$day_values[''] = '';
}

for ($i = 1; $i <= 31; $i++)
{
$days[] = sprintf($day_format, $i);
$day_values[] = sprintf($day_value_format, $i);
}

$day_result .= '<select name=';

if (null !== $field_array)
{
$day_result .= '"' . $field_array . '[';
$day_result .= (null !== $strDayFieldName) ?
$strDayFieldName.']"' : $prefix.'Day]"';
}
else
{
$day_result .= (null !== $strDayFieldName) ?
'"'.$strDayFieldName.'"' : '"'.$prefix.'Day"';
}

if (null !== $day_size)
{
$day_result .= ' size="' . $day_size . '"';
}

if (null !== $all_extra)
{
$day_result .= ' ' . $all_extra;
}

if (null !== $day_extra)
{
$day_result .= ' ' . $day_extra;
}

$day_result .= '>'."\n";
$day_result .= smarty_function_html_options(array('output'
=> $days,
'values'
=> $day_values,
'selected'
=> $time[2],
'print_result'
=> false),
$smarty);
$day_result .= '</select>';
}

if ($display_years)
{
if (null !== $field_array)
{
$year_name = $field_array . '[';
$year_name .= (null !== $strYearFieldName) ?
$strYearFieldName.']' : $prefix.'Year]';
}
else
{
$year_name .= (null !== $strYearFieldName) ?
$strYearFieldName : $prefix.'Year';
}

if ($year_as_text)
{
$year_result .= '<input type="text" name="' . $year_name .
'" value="' . $time[0] . '" size="4" maxlength="4"';
if (null !== $all_extra){
$year_result .= ' ' . $all_extra;
}
if (null !== $year_extra){
$year_result .= ' ' . $year_extra;
}
$year_result .= '>';
} else {
$years = range((int)$start_year, (int)$end_year);
if ($reverse_years) {
rsort($years, SORT_NUMERIC);
} else {
sort($years, SORT_NUMERIC);
}
$yearvals = $years;
if(isset($year_empty)) {
array_unshift($years, $year_empty);
array_unshift($yearvals, '');
}
$year_result .= '<select name="' . $year_name . '"';
if (null !== $year_size){
$year_result .= ' size="' . $year_size . '"';
}
if (null !== $all_extra){
$year_result .= ' ' . $all_extra;
}
if (null !== $year_extra){
$year_result .= ' ' . $year_extra;
}
$year_result .= '>'."\n";
$year_result .= smarty_function_html_options(array('output'
=> $years,
'values'
=> $yearvals,

'selected' => $time[0],

'print_result' => false),
$smarty);
$year_result .= '</select>';
}
}

// Loop thru the field_order field
for ($i = 0; $i <= 2; $i++){
$c = substr($field_order, $i, 1);
switch ($c){
case 'D':
$html_result .= $day_result;
break;

case 'M':
$html_result .= $month_result;
break;

case 'Y':
$html_result .= $year_result;
break;
}
// Add the field seperator
if($i != 2) {
$html_result .= $field_separator;
}
}

return $html_result;
}

/* vim: set expandtab: */

?>



Monte Ohrt wrote:
> What is the name of the plugin file, and what is the content? Do you
> have one plugin directory, or multiple?
>
> Erich C. Beyrent wrote:
>> That's how it appears to me, but I'm not sure why that is happening,
>> or how to fix it.
>>
>> -Erich-
>>
>> Dean Ariel wrote:
>>> Maybe it's not including the plugins when it's compiled ??
>>>
>>> Dean
>>>
>>> On 11/3/06, Erich C. Beyrent <erich.beyrent@beyrent.net> wrote:
>>>> Jochem Maas wrote:
>>>> > Erich C. Beyrent wrote:
>>>> >
>>>> >> I have written a plugin called html_select_date2, and it is
>>>> giving me
>>>> >> some trouble. The first time the page loads, the function is
>>>> called and
>>>> >> everything works smashingly. However, if I refresh the page, I
>>>> get this:
>>>> >> *
>>>> >> Fatal error*: Call to undefined function:
>>>> >> smarty_function_html_select_date2() in
>>>> >>
>>>> */public_html/php/templates_c/%%24^24D^24D5865F%%default.form.tpl.php*
>>>> >> on line *97
>>>> >>
>>>> >> *Is this a permissions problem, or is something else going on here?
>>>> >>
>>>> >
>>>> > the function is not being loaded. what I do is stick all my custom
>>>> > smarty plugins in a directory and then add that directory to the
>>>> list of
>>>> > plugin dirs - that way Smarty will always be able to find/load
>>>> your plugins
>>>> >
>>>> >
>>>> LOL
>>>>
>>>> In the Why Use Smarty page, it says:
>>>>
>>>> "Adding custom features to Smarty is as easy as dropping them in the
>>>> plugin directory and mentioning them in the template."
>>>>
>>>> So that's exactly what I did. What I don't understand is why the
>>>> plugin
>>>> works fine the first time the page loads, but fails when you
>>>> refresh the
>>>> browser. Why does it get loaded the first time, but not from the
>>>> compiled template?
>>>>
>>>> -Erich-
>>>>
>>>> --
>>>> Smarty General Mailing List (http://smarty.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>
>>>

>>

>

  Réponse avec citation
Vieux 03/11/2006, 16h51   #7
Monte Ohrt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

The important part is that the file name and function name are correct,
and they appear to be. You mentioned html_select_date has the same
problem. Do any other plugins exhibit this behavior?

Erich C. Beyrent wrote:
> Before I get into specifics, I should point out that I tested this
> problem using the standard html_select_date plugin, and saw the exact
> same behavior, so I don't think the problem is my plugin itself. I
> believe there is some kind of issue with my environment.
>
> I have a single plugin directory, which is the main
> {smarty_dir}/libs/plugins directory.
> The name of the plugin file is function.html_select_date2.php, which
> is based upon the original html_select_date function. My modded file
> allows me to override the names of the fields like this:
>
> {html_select_date2 field_name="FromMonth,FromDay,FromYear"
> day_extra="id=FromDay class=dateSelect" month_extra="id=FromMonth
> class=dateSelect" year_extra="id=FromYear class=dateSelect"
> end_year="+2"}
>
> The contents are as follows (this is gonna be long...):
>
> function smarty_function_html_select_date2($params, &$smarty)
> {
> /* vim: set expandtab: */
>
> ?>

  Réponse avec citation
Vieux 03/11/2006, 16h58   #8
Erich C. Beyrent
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

Yes - I just saw the same behavior with the {debug} function.

Monte Ohrt wrote:
> The important part is that the file name and function name are
> correct, and they appear to be. You mentioned html_select_date has the
> same problem. Do any other plugins exhibit this behavior?
>
> Erich C. Beyrent wrote:
>> Before I get into specifics, I should point out that I tested this
>> problem using the standard html_select_date plugin, and saw the exact
>> same behavior, so I don't think the problem is my plugin itself. I
>> believe there is some kind of issue with my environment.
>>
>> I have a single plugin directory, which is the main
>> {smarty_dir}/libs/plugins directory.
>> The name of the plugin file is function.html_select_date2.php, which
>> is based upon the original html_select_date function. My modded file
>> allows me to override the names of the fields like this:
>>
>> {html_select_date2 field_name="FromMonth,FromDay,FromYear"
>> day_extra="id=FromDay class=dateSelect" month_extra="id=FromMonth
>> class=dateSelect" year_extra="id=FromYear class=dateSelect"
>> end_year="+2"}
>>
>> The contents are as follows (this is gonna be long...):
>>
>> function smarty_function_html_select_date2($params, &$smarty)
>> {
>> /* vim: set expandtab: */
>>
>> ?>

>

  Réponse avec citation
Vieux 03/11/2006, 17h27   #9
Monte Ohrt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

Seems that something is amiss in your environment... do all the plugins
fail after the first page load? Are you using any Smarty caching?

Erich C. Beyrent wrote:
> Yes - I just saw the same behavior with the {debug} function.
>
> Monte Ohrt wrote:
>> The important part is that the file name and function name are
>> correct, and they appear to be. You mentioned html_select_date has
>> the same problem. Do any other plugins exhibit this behavior?
>>
>> Erich C. Beyrent wrote:
>>> Before I get into specifics, I should point out that I tested this
>>> problem using the standard html_select_date plugin, and saw the
>>> exact same behavior, so I don't think the problem is my plugin
>>> itself. I believe there is some kind of issue with my environment.
>>>
>>> I have a single plugin directory, which is the main
>>> {smarty_dir}/libs/plugins directory.
>>> The name of the plugin file is function.html_select_date2.php, which
>>> is based upon the original html_select_date function. My modded
>>> file allows me to override the names of the fields like this:
>>>
>>> {html_select_date2 field_name="FromMonth,FromDay,FromYear"
>>> day_extra="id=FromDay class=dateSelect" month_extra="id=FromMonth
>>> class=dateSelect" year_extra="id=FromYear class=dateSelect"
>>> end_year="+2"}
>>>
>>> The contents are as follows (this is gonna be long...):
>>>
>>> function smarty_function_html_select_date2($params, &$smarty)
>>> {
>>> /* vim: set expandtab: */
>>>
>>> ?>

>>

>

  Réponse avec citation
Vieux 03/11/2006, 17h51   #10
Erich C. Beyrent
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

I did not go through all the plugins, but three failed, so I will
venture to guess that yes, they all fail on page refresh. I have
caching disabled.

If I enable caching and specify a cache id, it works fine. I am not
sure this is a good thing though, especially where I am working with
dynamically generated date forms.

Monte Ohrt wrote:
> Seems that something is amiss in your environment... do all the
> plugins fail after the first page load? Are you using any Smarty caching?
>
> Erich C. Beyrent wrote:
>> Yes - I just saw the same behavior with the {debug} function.
>>
>> Monte Ohrt wrote:
>>> The important part is that the file name and function name are
>>> correct, and they appear to be. You mentioned html_select_date has
>>> the same problem. Do any other plugins exhibit this behavior?
>>>
>>> Erich C. Beyrent wrote:
>>>> Before I get into specifics, I should point out that I tested this
>>>> problem using the standard html_select_date plugin, and saw the
>>>> exact same behavior, so I don't think the problem is my plugin
>>>> itself. I believe there is some kind of issue with my environment.
>>>>
>>>> I have a single plugin directory, which is the main
>>>> {smarty_dir}/libs/plugins directory.
>>>> The name of the plugin file is function.html_select_date2.php,
>>>> which is based upon the original html_select_date function. My
>>>> modded file allows me to override the names of the fields like this:
>>>>
>>>> {html_select_date2 field_name="FromMonth,FromDay,FromYear"
>>>> day_extra="id=FromDay class=dateSelect" month_extra="id=FromMonth
>>>> class=dateSelect" year_extra="id=FromYear class=dateSelect"
>>>> end_year="+2"}
>>>>
>>>> The contents are as follows (this is gonna be long...):
>>>>
>>>> function smarty_function_html_select_date2($params, &$smarty)
>>>> {
>>>> /* vim: set expandtab: */
>>>>
>>>> ?>
>>>

>>

>

  Réponse avec citation
Vieux 03/11/2006, 21h39   #11
boots
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

Without knowing anything about your environment, my first thought on this is to guess that you are probably using sessions and serializing the Smarty object. If so, then don't. The Smarty object should never be serialized because it contains environment specific state information that may not be true once it is unserialized.

xo boots

"Erich C. Beyrent" <erich.beyrent@beyrent.net> wrote: I did not go through all the plugins, but three failed, so I will
venture to guess that yes, they all fail on page refresh. I have
caching disabled.

If I enable caching and specify a cache id, it works fine. I am not
sure this is a good thing though, especially where I am working with
dynamically generated date forms.

Monte Ohrt wrote:
> Seems that something is amiss in your environment... do all the
> plugins fail after the first page load? Are you using any Smarty caching?
>
> Erich C. Beyrent wrote:
>> Yes - I just saw the same behavior with the {debug} function.
>>
>> Monte Ohrt wrote:
>>> The important part is that the file name and function name are
>>> correct, and they appear to be. You mentioned html_select_date has
>>> the same problem. Do any other plugins exhibit this behavior?
>>>
>>> Erich C. Beyrent wrote:
>>>> Before I get into specifics, I should point out that I tested this
>>>> problem using the standard html_select_date plugin, and saw the
>>>> exact same behavior, so I don't think the problem is my plugin
>>>> itself. I believe there is some kind of issue with my environment.
>>>>
>>>> I have a single plugin directory, which is the main
>>>> {smarty_dir}/libs/plugins directory.
>>>> The name of the plugin file is function.html_select_date2.php,
>>>> which is based upon the original html_select_date function. My
>>>> modded file allows me to override the names of the fields like this:
>>>>
>>>> {html_select_date2 field_name="FromMonth,FromDay,FromYear"
>>>> day_extra="id=FromDay class=dateSelect" month_extra="id=FromMonth
>>>> class=dateSelect" year_extra="id=FromYear class=dateSelect"
>>>> end_year="+2"}
>>>>
>>>> The contents are as follows (this is gonna be long...):
>>>>
>>>> function smarty_function_html_select_date2($params, &$smarty)
>>>> {
>>>> /* vim: set expandtab: */
>>>>
>>>> ?>
>>>

>>

>


--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited Try it today.
  Réponse avec citation
Vieux 04/11/2006, 02h43   #12
Erich C. Beyrent
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

boots wrote:
> Without knowing anything about your environment, my first thought on
> this is to guess that you are probably using sessions and serializing
> the Smarty object. If so, then don't. The Smarty object should never
> be serialized because it contains environment specific state
> information that may not be true once it is unserialized.
>
> xo boots
>
> *//*

I am using sessions and storing the Smarty object in the session so that
I can use it all over the site. I inherited a rat's nest of code, and
was trying to prevent having to create new Smarty objects all over the
place, but from what you are saying, that's what I am going to have to do?

-Erich-
  Réponse avec citation
Vieux 04/11/2006, 03h33   #13
Erich C. Beyrent
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

boots wrote:
> Without knowing anything about your environment, my first thought on
> this is to guess that you are probably using sessions and serializing
> the Smarty object. If so, then don't. The Smarty object should never
> be serialized because it contains environment specific state
> information that may not be true once it is unserialized.
>
> xo boots

Ok, I have made sure I am using the most current stable version of
Smarty. I have cleared my compiled templates. I have created a new
Smarty object. Sadly, the problem is still present. I tried to
manually load the plugin, and that failed as well.

What is going on here?

-Erich-
  Réponse avec citation
Vieux 04/11/2006, 19h30   #14
Jochem Maas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Plugin problem

Erich C. Beyrent wrote:
> boots wrote:
>> Without knowing anything about your environment, my first thought on
>> this is to guess that you are probably using sessions and serializing
>> the Smarty object. If so, then don't. The Smarty object should never
>> be serialized because it contains environment specific state
>> information that may not be true once it is unserialized.
>>
>> xo boots
>>
>> *//*

> I am using sessions and storing the Smarty object in the session so that
> I can use it all over the site. I inherited a rat's nest of code, and
> was trying to prevent having to create new Smarty objects all over the
> place, but from what you are saying, that's what I am going to have to do?


// write a simple function (not sure if/where you need/want to use the references
// for the Smarty object var):

function &getSmart()
{
static $smarty;

if (!isset($smarty)) {
$smarty = new Smarty;
/* do some config */
}

return $smarty;
}

class someJunkyClassWrittenBySomeoneEvenLessCapableThanM e
{
function foo()
{
/* lots of rubbish code */

$s = getSmart();
$s->assign('foo', $foo);
return $s->fetch($templatefile);
}
}


// alternatively use a global variable reference.

function someJunkyRoutineWrittenBySomeoneEvenLessCapableTha nMe()
{
global $myGlobalSmartyObject;

/* lots of rubbish code */

$myGlobalSmartyObject->assign('foo', $foo);
return $myGlobalSmartyObject->fetch($templatefile);
}

>
> -Erich-
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h18.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,32800 seconds with 22 queries