Forums / Developer / How to pass varaibles from php to templates
Felix Laate
Friday 16 December 2005 2:14:16 am
Hi all!
I'm pretty green on developing modules, but know I'm trying to do it anyway.
I have a module which does some stuff. Then I whant it to repport to the user what happend.
I have some php:
include_once( "kernel/common/template.php" ); $Module =& $Params["Module"]; $tpl =& templateInit(); $tpl->setVariable('testing', 'This is a boring text!'); $Result = array(); $Result['content'] =& $tpl->fetch( "design:mymodule/feedback.tpl" ); $Result['path'] = array( array( 'url' => '/mymodule/feedback', 'text' => 'test' ) );
Then I have a template:
<h1>My pretty boring module</h1> <strong>TEST: {$testing}</strong>
Unfortunatly <i>{$testing}</i> doesn't give me anything. The docs I found suggest that this is the way to pass variable from php to the template.
Any help could fix my headache..
Felix
Publlic Relations Manager Greater Stavanger www.greaterstavanger.com
Gabriel Ambuehl
Friday 16 December 2005 7:33:50 am
The way described in the docs works for me. Are you seeing the rest of the template?
Visit http://triligon.org
Friday 16 December 2005 9:32:55 am
Hi Gabriel!
Yes, the title im the <H1> tag is shown..
A bit strange isn't it?
PS! I run 3.7.1
Xavier Dutoit
Friday 16 December 2005 9:52:52 am
I use the same code you describe and it works.
Do you have errors/warning on the debug (set it on, clear all caches and run your module again).
X+
http://www.sydesy.com
Friday 16 December 2005 10:23:51 am
Hi Xavier!
Unfortunatly it only says the module started and the module ended. No further messages..
I'm working on a module for integration of ez and openlaszlo (dynamic flash). Actually there will be two modules: a designer and a packagemanager. Currently I'm working on the latter.
I can get the php-script(s) to do things in the background, but when it comes to feedback it just won't do it..
Norman Leutner
Thursday 29 December 2005 7:59:52 am
Silly question:cleared all caches?
Mit freundlichen Grüßen Best regards Norman Leutner ____________________________________________________________ eZ Publish Platinum Partner - http://www.all2e.com http://ez.no/partners/worldwide_partners/all2e_gmbh
Thursday 29 December 2005 9:26:09 am
Hi Norman!
Not a silly question.. done that error a million times, but not this time..
Petter Arneson
Thursday 29 December 2005 11:58:46 am
I don't know if this helps, but another silly question: did you enable the extension in admin? and in the settings?
It probably doesn't mather, but try
$Result['content'] = $tpl->fetch( "design:mymodule/feedback.tpl" );
instead of
$Result['content'] =& $tpl->fetch( "design:mymodule/feedback.tpl" );
Or have you tried the full path to the template?
$Result['content'] =& $tpl->fetch( "extension/mymodule/design/standard/templates/mymodule/feedback.tpl" );
www.vzt.no