How to pass varaibles from php to templates

Author Message

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

Felix Laate

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?

Felix

PS! I run 3.7.1

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

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

Felix Laate

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..

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

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

Felix Laate

Thursday 29 December 2005 9:26:09 am

Hi Norman!

Not a silly question.. done that error a million times, but not this time..

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 01:16:35
Script start
Timing: Jan 31 2025 01:16:35
Module start 'layout'
Timing: Jan 31 2025 01:16:35
Module start 'content'
Timing: Jan 31 2025 01:16:36
Module end 'content'
Timing: Jan 31 2025 01:16:36
Script end

Main resources:

Total runtime1.2749 sec
Peak memory usage8,192.0000 KB
Database Queries78

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0037 588.2656151.2266
Module start 'layout' 0.00370.0036 739.4922220.7188
Module start 'content' 0.00731.2667 960.21094,617.5391
Module end 'content' 1.27400.0009 5,577.750019.8125
Script end 1.2748  5,597.5625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.2684160.0002
Check MTime0.00130.1020160.0001
Mysql Total
Database connection0.00070.051810.0007
Mysqli_queries1.158290.8466780.0148
Looping result0.00070.0548760.0000
Template Total1.219895.720.6099
Template load0.00220.169120.0011
Template processing1.217795.511820.6088
Template load and register function0.00130.105110.0013
states
state_id_array0.00100.081810.0010
state_identifier_array0.00160.123320.0008
Override
Cache load0.00200.1559520.0000
Sytem overhead
Fetch class attribute can translate value0.00170.133250.0003
Fetch class attribute name0.00200.1554110.0002
XML
Image XML parsing0.00340.268950.0007
class_abstraction
Instantiating content class attribute0.00000.0024140.0000
General
dbfile0.00280.2191290.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs