subtemplates - best practice - combining script output

From: Date: Thu, 29 Aug 2002 08:24:11 +0000
Subject: subtemplates - best practice - combining script output
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5868@lists.php.net to get a copy of this message
Hi, I'm trying to make a main template that includes - static data by including subtemplates via {include} - dynamic data by including php-files (which themselves use templates) via {include_php} This is the main php-file (wrapper.php): <?php //Include dir_config require_once('dir_config.php'); //Set variables $lang='nl'; $mainsmarty = new Smarty_BVICB; $mainsmarty->assign_by_ref("lang",$lang); $mainsmarty->display("wrapper.tpl"); ?> This is main template (wrapper.tpl): {* Smarty *} <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> {include file="header.tpl"} {include_php file="menuscript.php"} </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%" height="500"> <tr valign="top"> <td height="90" colspan="2"> {include_php file="menu.php"} </td> </tr> <tr valign="top"> <td width="112" align="center" valign="top"> {include_php file="submenu.php"} </td> <td width="90%" class="contentcel"> {include_php file="test_group.php"} </td> </tr> <tr> <td colspan="3" height="20"> {include file="footer.tpl"} </td> </tr> </table> </body> </html> I get following error: Fatal error: Call to a member function on a non-object in menuscript.php on line 8 menuscript.php is: <script language="JavaScript" type="text/javascript"> function fwLoadMenus() { if (window.fw_menu_0) return; //submenu window.fw_menu_0_1 = new Menu("<?php echo langChoice("Werkgroepen","Groupes de Travail","Committees",$lang) ?>",130,20,"Verdana, Arial, Helvetica, sans-serif",9,"#cccccc","#ffffff","#31628a","#094569"); // lijst werkgroepen <?php $data=$user->getGroups(array("gid","name_".$lang), array(array("field"=>"type","value"=>"PWG","match"=>"contains")), array("orderby"=>"name_".$lang)); //lijst alle PWG's while ( list($key, $val) = each($data)){ $werkgroep=htmlentities($val["name_".$lang]); print "fw_menu_0_1.addMenuItem(\"".$werkgroep."\",\"location='".$content_path."org anisatie/index.php?file=werkgroepen&gid=".$val["gid"]."&lang=".$lang."'\");\ n"; } ?> //fw_menu_0_1.bgImageOver="<?php echo $htdocs_path ?>images/menubutton_over.gif"; //fw_menu_0_1.bgImageUp="<?php echo $htdocs_path ?>images/menubutton_up.gif"; fw_menu_0_1.hideOnMouseOut=true; (...) line 8 is: $data=$user->getGroups(array("gid... $user is an object of a class that is included via dir_config.php in the main php-file. On the other hand, this (main php-file that does not use a template) works fine but mixes php and html: <?php //Include dir_config require_once('dir_config.php'); //Set variables $lang='nl'; $mainsmarty = new Smarty_BVICB; $mainsmarty->assign_by_ref("lang",$lang); echo' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <!-- header --> '; $mainsmarty->display('header.tpl'); include('menuscript.php'); echo' </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%" height="500"> <tr valign="top"> <td height="90" colspan="2"> <!-- main menu --> '; include('menu.php'); echo' </td> </tr> <tr valign="top"> <td width="112" align="center" valign="top">&nbsp; <!-- submenu --> '; $mainsmarty->display('submenu.tpl'); //include('submenu.php'); echo' </td> <!-- content --> <td width="90%" class="contentcel"> '; include('test_group.php'); echo' </td> </tr> <tr> <td colspan="3" height="20"> <!-- footer --> '; $mainsmarty->display('footer.tpl'); echo' </td> </tr> </table> </body> </html> '; ?> Any idea how to make the wrapper.tpl work? Tnx Tom

« previous php.smarty.general (#5868) next »