Forums / Developer / How to pass varaibles from php to templates

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

eZ debug

Timing: Jan 31 2025 01:16:20
Script start
Timing: Jan 31 2025 01:16:20
Module start 'content'
Timing: Jan 31 2025 01:16:20
Module end 'content'
Timing: Jan 31 2025 01:16:20
Script end

Main resources:

Total runtime0.1976 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0077 589.1953370.2734
Module start 'content' 0.00770.0130 959.46881,009.7031
Module end 'content' 0.02070.1768 1,969.17193,898.7891
Script end 0.1975  5,867.9609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00442.2027200.0002
Check MTime0.00130.6603200.0001
Mysql Total
Database connection0.00080.415010.0008
Mysqli_queries0.102952.10181410.0007
Looping result0.00150.73631390.0000
Template Total0.176489.310.1764
Template load0.00070.348210.0007
Template processing0.175788.921310.1757
Override
Cache load0.00050.235310.0005
Sytem overhead
Fetch class attribute can translate value0.00221.101810.0022
XML
Image XML parsing0.00030.133110.0003
General
dbfile0.00512.6043200.0003
String conversion0.00000.003130.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs