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 > Custom resources
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Custom resources

Réponse
 
LinkBack Outils de la discussion
Vieux 04/05/2006, 02h40   #1
Eric Mueller
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Custom resources

Hi, hoping someone can me with this. I am working on a custom resource
handler must be missing something obvious...? Why is this giving me this
error: "Warning: Smarty error: unable to read resource: "db:blah" in
C:\htdocs\cms\libs\Smarty.class.php on line 1095"?


<?php

require_once('libs/Smarty.class.php');

$smarty = new Smarty;

function db_source($tpl_name, &$tpl_source, &$smarty_obj) {
$tpl_source = "You asked for $tpl_name.";
return true;
}

function db_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) {
return false; // it's always new
}

function db_secure($tpl_name, &$smarty_obj) {
// assume all templates are secure
return true;
}

function db_trusted($tpl_name, &$smarty_obj) {
// not used for templates
return true;
}


// register the resource name "db"
$smarty->register_resource("db", array( "db_source",
"db_timestamp",
"db_secure",
"db_trusted" ) );

$smarty->display('db:blah');

?>



_____
Eric Mueller - (323) 852-0883 (Pacific time), (323) 417-4900 fax
Themepark - a specialized web services company
"great web sites, delicious corn dogs!"
<http://themepark.com/> http://themepark.com

A Cappella Always, the 24x7 all-a cappella radio station!
broadcasting since 2001 at <http://acappellaalways.com/>
http://acappellaalways.com


  Réponse avec citation
Vieux 04/05/2006, 07h11   #2
boots
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Custom resources

--- Eric Mueller <eric@ericmueller.org> wrote:
> Hi, hoping someone can me with this. I am working on a custom resource
> handler must be missing something obvious...? Why is this giving me this
> error: "Warning: Smarty error: unable to read resource: "db:blah" in
> C:\htdocs\cms\libs\Smarty.class.php on line 1095"?
>
>
> <?php
>
> require_once('libs/Smarty.class.php');
>
> $smarty = new Smarty;
>
> function db_source($tpl_name, &$tpl_source, &$smarty_obj) {
> $tpl_source = "You asked for $tpl_name.";
> return true;
> }
>
> function db_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) {
> return false; // it's always new
> }



Hi.

You return false only on failure -- ie: you can't determine the timestamp at
all. The implied condition is then that you can't locate the requested resource
item. Otherwise, you should return true and populate $tpl_timestamp with the
proper timestamp. If you want non-expiring templates and don't intend to
look-up the proper timestamp, set the timestamp for $tpl_timestamp to now
(perhaps with time()).

HTH


> function db_secure($tpl_name, &$smarty_obj) {
> // assume all templates are secure
> return true;
> }
>
> function db_trusted($tpl_name, &$smarty_obj) {
> // not used for templates
> return true;
> }
>
>
> // register the resource name "db"
> $smarty->register_resource("db", array( "db_source",
> "db_timestamp",
> "db_secure",
> "db_trusted" ) );
>
> $smarty->display('db:blah');
>
> ?>



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
  Réponse avec citation
Vieux 04/05/2006, 07h52   #3
Eric Mueller
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [SMARTY] Custom resources

Thank you so much! E


> > function db_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) {
> > return false; // it's always new
> > }

>
> Hi.
>
> You return false only on failure -- ie: you can't determine
> the timestamp at
> all. The implied condition is then that you can't locate the
> requested resource
> item. Otherwise, you should return true and populate
> $tpl_timestamp with the
> proper timestamp. If you want non-expiring templates and
> don't intend to
> look-up the proper timestamp, set the timestamp for
> $tpl_timestamp to now
> (perhaps with time()).
>
> HTH

  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 20h24.


É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,09756 seconds with 11 queries