Including a template into a template several times. Another try.

From: Date: Mon, 06 Oct 2003 13:38:34 +0000
Subject: Including a template into a template several times. Another try.
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10307@lists.php.net to get a copy of this message
Hi, I spent the entire last week trying to figure out what I am doing wrong. Inside the template "news.tpl" I include the template "menu.tpl" several times, since they are menu tables of the same structure. For each product category I created its own array. Somebody the fabulous idea to pass an array of arrays. So I did. And still it doesn't work. I am really giving up on this problem. I really doubt that I will ever find the solution of this problem on my own. Could please somebody tell me what I am doing wrong? Thank you so much!! function initMenu() { $menu = array(); $this->oGipsMenu = new Menutable_Gipse($this->aTrans['gipse'], $this->aTrans); $this->oModelMenu = new Menutable($this->aTrans['modelherstellung'], $this->aTrans); $this->oEinbettMenu = new Menutable($this->aTrans['einbettmassen'], $this->aTrans); $this->oLabMenu = new Menutable($this->aTrans['laborhilfsmittel'], $this->aTrans); array_push($menu, $this->oGipsMenu->menuItems, $this->oLabMenu->menuItems, $this->oModelMenu->menuItems, $this->oEinbettMenu->menuItems, $this->oLabMenu->menuItems); $this->assignVars("menu", $menu); $this->assignVars('menuSpecs', $menuSpecs); } class Menutable_Gipse extends Menutable { function Menutable_Gipse($categoryHeader, $aTrans) { $this->menuSpecs['tableWidthPx'] = "240"; // Variable that determines the centerpiece of the table $this->menuSpecs['outerBorderWidth'] = "0"; $this->categoryHeader = $categoryHeader; ## GIPSE ## $this->menuItems[0][0] = "1010"; $this->menuItems[0][1] = $aTrans['stumpfgipseTyp4']; $this->menuItems[1]['id'] = "1015"; $this->menuItems[1]['trans'] = $aTrans['superhartgipsTyp4']; $this->menuItems[2]['id'] = "1020"; $this->menuItems[2]['trans'] = $aTrans['sockelgipsTyp4']; $this->menuItems[3]['id'] = "1030"; $this->menuItems[3]['trans'] = $aTrans['artikulationsgips']; $this->menuItems[4]['id'] = "1040"; $this->menuItems[4]['trans'] = $aTrans['praesentationsgips']; $this->menuItems[5]['id'] = "1050"; $this->menuItems[5]['trans'] = $aTrans['spezialgipsFuerCerecTyp4']; $this->menuItems[6]['id'] = "1060"; $this->menuItems[6]['trans'] = $aTrans['superhartgipsTyp5']; $this->menuItems[7]['id'] = "1070"; $this->menuItems[7]['trans'] = $aTrans['hartgipsTyp3']; } } function assignVars($varname, $value) { // if varname is not passed assign keys and values if (($varname == "") & (isset($value))) { while (list($key, $val) = each($value)) { $this->smarty->assign($key, $val); } } elseif (isset($varname) & isset($value)) { $this->smarty->assign($varname, $value); } } ---------------------------------------------------------------------------- ---- Finally the spot in the template "news" where I include the other template. <td width="25%" valign="top" align="left"> {foreach from=$menu item=menuItems} {include file="menu.tpl" menuItems=$menuItems} <br /> {/foreach} </td> Thx a bunch!!! Webmaster

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