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

register_function and objects

 
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 -> General
View previous topic :: View next topic  
Author Message
gerard
Smarty Regular


Joined: 18 Apr 2003
Posts: 84

PostPosted: Fri Jul 11, 2003 8:58 am    Post subject: register_function and objects Reply with quote

Just wondering if/when this will be implemented:

$smarty->register_function("date_now", array($obj, "print_current_date"));

Thx
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Fri Jul 11, 2003 2:36 pm    Post subject: Reply with quote

it's already done in the cvs-version of smarty. see http://smarty.php.net/download.php on how to get it
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gerard
Smarty Regular


Joined: 18 Apr 2003
Posts: 84

PostPosted: Mon Jul 21, 2003 8:10 pm    Post subject: Reply with quote

Any idea when the next version of Smarty will be released?
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Jul 22, 2003 10:15 pm    Post subject: Reply with quote

when performance of the cvs-version is bettor-or-equal (hopefully better, of course) than the one of 2.5.0 there will be a release candidate. things may change under the hood after that, but no new features should appear or vanish after the rc until the next version is stable and final.

i don't know when this will be regarding absolute time measures.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
phod
Smarty n00b


Joined: 29 Jul 2003
Posts: 4

PostPosted: Tue Jul 29, 2003 10:33 pm    Post subject: Something similar? Reply with quote

Sorry guys, its getting late and im wrestling with a problem...i've written a CMS - and now i've come to the point of needing module support, i've decided to go with the "each module is a class" approach, and have serialised GET vars for them and everything, and to control, how and where they appear - im going with smarty function calls stored in a mySQL databsae, in the order they are to be used...OK so far - my problem comes of course when i realise that i need to somehow register a member function from a class into smarty, and ............... well it dosent want to let me!!

heres my plugin loader code:
[php:1:4f6635fdfc]<?php
$plugin_dir = opendir($dir['plugin_dir']);
while( false != ($file = readdir($plugin_dir)) ){
if($file != '.' && $file != '..'){
include_once($dir['plugin_dir'] . $file);
$parts = explode('.', $file);
if($parts[0] == 'plugin'){
$$parts[1] = &new $parts[1];
/*
$_SESSION['plugins'][$parts[1]] = $$parts[1];
$_SESSION['plugins'][$parts[1]]->init();
$_SESSION['plugins'][$parts[1]]->cms = &$cms;
*/
$cms->register_function($parts[1] . '_init', $$parts[1]->init()); $cms->register_function($parts[1] . '_display', $$parts[1]->display());
/* print_r($cms); */
}
}
}
?>[/php:1:4f6635fdfc]

and one of the example plugins from the plugins dir:

[php:1:4f6635fdfc]<?php
class error_mod{

var $local_var = "foo";
var $cms;

function error_mod(){
#echo "Error Module Loaded Correctly.<br />";
}
function init(){
$echo .= $_html_code[OpenTable0];
$echo .= $_html_code[OpenRow];
$echo .= $_html_code[OpenHeaderCell];
$echo .= "Error Mod Plugin.";
$echo .= $_html_code[CloseCell];
$echo .= $_html_code[CloseRow];
$echo .= $_html_code[OpenRow];
$echo .= $_html_code[OpenDataCell];
$echo .= "Some Data here, like your IP address, " . $_SERVER['REMOTE_ADDR'];
$echo .= $_html_code[CloseCell];
$echo .= $_html_code[CloseRow];
$echo .= $_html_code[CloseTable];
return $echo;
}
}
?>[/php:1:4f6635fdfc]

maybe im doing something wrong in my $cms->register_function, maybe its smarty...but it seems that this page is talking about my problem...maybe i missed the point - any help would be GREATLY appreciated....thanks in advance
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Jul 30, 2003 9:10 am    Post subject: Reply with quote

the correct syntax for that is:

Code:

$cms->register_function($parts[1] . '_init', array(&$$parts[1], 'init'));
$cms->register_function($parts[1] . '_display', array(&$$parts[1], 'display'));
Back to top
View user's profile Send private message Send e-mail Visit poster's website
phod
Smarty n00b


Joined: 29 Jul 2003
Posts: 4

PostPosted: Wed Jul 30, 2003 7:24 pm    Post subject: Reply with quote

Thankyou very much sir Very Happy , unfortunatly the java guy im working with almost castrated me for not telling him he could use some class->member typed scripting for the backend of the site.....so looke ikeregister_objet was what was called for....muchos gracious anyway Embarassed
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 -> General 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