|
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 |
orangehairedboy Smarty n00b
Joined: 01 Nov 2004 Posts: 1 Location: Tampa, FL
|
Posted: Mon Nov 01, 2004 3:49 am Post subject: Using a custom resource for getting templates |
|
|
I'm attempting to impliment the database example on this page:
http://smarty.php.net/manual/en/template.resources.php
I would like to place the functions inside a class I already have so it can access the database routines I already have.
For example:
Code: | $smarty = new Smarty;
$SFNG = new SFNG;
$smarty->register_resource( "sfng" , ????????????????? );
class SFNG {
function sfng_get_template( $tpl_name , &$tpl_source , &$smarty_obj ) {
$tpl_source = $this->doQuery( "..." );
return TRUE;
}
function doQuery( $query );
} |
What should go where the ?????????????????? is to make it work? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Nov 01, 2004 5:56 pm Post subject: |
|
|
I never tried this, but I the following might work:
$smarty->register_resource('SFNG', array(
array(&$SFNG, 'sfng_get_template'),
array(&$SFNG, 'sfng_get_timestamp'),
array(&$SFNG, 'sfng_get_secure'),
array(&$SFNG, 'sfng_get_trusted')
));
ie. try using the standard PHP callback syntax. I figure that I can check the sources to see if this will work or you can actually try it out to see what happens. Let us know |
|
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
|