Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Using a custom resource for getting templates

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
orangehairedboy
Smarty n00b


Joined: 01 Nov 2004
Posts: 1
Location: Tampa, FL

PostPosted: Mon Nov 01, 2004 3:49 am    Post subject: Using a custom resource for getting templates Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Nov 01, 2004 5:56 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP