|
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 |
gerard Smarty Regular
Joined: 18 Apr 2003 Posts: 84
|
Posted: Fri Jul 11, 2003 8:58 am Post subject: register_function and objects |
|
|
Just wondering if/when this will be implemented:
$smarty->register_function("date_now", array($obj, "print_current_date"));
Thx |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
|
Back to top |
|
gerard Smarty Regular
Joined: 18 Apr 2003 Posts: 84
|
Posted: Mon Jul 21, 2003 8:10 pm Post subject: |
|
|
Any idea when the next version of Smarty will be released? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Jul 22, 2003 10:15 pm Post subject: |
|
|
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 |
|
phod Smarty n00b
Joined: 29 Jul 2003 Posts: 4
|
Posted: Tue Jul 29, 2003 10:33 pm Post subject: Something similar? |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Jul 30, 2003 9:10 am Post subject: |
|
|
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 |
|
phod Smarty n00b
Joined: 29 Jul 2003 Posts: 4
|
Posted: Wed Jul 30, 2003 7:24 pm Post subject: |
|
|
Thankyou very much sir , 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 |
|
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
|