For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > May 2006 > Custom resources









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Custom resources
Eric Mueller

2006-05-03, 7:07 pm

Hi, hoping someone can help 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


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com