|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
roli Smarty n00b
Joined: 27 Sep 2004 Posts: 1
|
Posted: Mon Sep 27, 2004 6:46 pm Post subject: menü mit temlates |
|
|
hallo
also ich möchte ein menü mit smaty machen.
im styl:
Downloads
Liks
Members
bis jetzt habe ich:
index.php
Code: | <?php
require '../libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->debugging = true;
$smarty->assign("wilkomen","Herzlich Wilkomen auf meiner homepage!");
$links = array("News","Downloads","links","kontakt","mehr");
$menu = array();
foreach ($links as $value){
$smarty->assign("menu",$links);
$menu[] = $smarty->fetch("menu.html");
}
$smarty->assign("links",$menu);
$smarty->display('master.html');
?> |
master.html
Code: | <div align="center">
<center>
<table border="0" vAlign=top width="100%" height="114" id="head">
<tr>
<td width="875" height="114">
{$wilkomen}
</td>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" width="100%" height="361" id="body">
<tr>
<td width="20%" height="361" valign="top" id="rechts">
</td>
<td width="60%" height="361" valign="top" id="mitte">
</td>
<td width="20%" height="361" id="links"
{ foreach item=item from=$links }
{ $links }
{ /foreach }
</td>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" width="100%" height="60" id="foot">
<tr>
<td width="100%" height="32">
</td>
</tr>
</table>
</center>
</div> |
menu.html
Code: | <i><b>{$menu}</b></i> |
wenn ich die seite öffne steht am entsprichenden ort immer nur:
Array
Array
Array
Array
Array
was ist falsch.
ich möcht nämlich, das in der vaiable $menu die links gepakt werden.
mfg Roland |
|
Back to top |
|
crashmakerMX Guest
|
Posted: Fri Oct 01, 2004 6:40 pm Post subject: Re: menü mit temlates |
|
|
roli wrote: |
Code: |
foreach ($links as $value){
$smarty->assign("menu",$links);
$menu[] = $smarty->fetch("menu.html");
}
|
|
du weist der smarty-varialbe 'menu' nicht den array-eintrag $value sondern das array $links selbst zu. ein ganz einfacher schreibfehler (sowas passiert mir auch oft)
richtig wäre es so
Code: |
foreach ($links as $value){
$smarty->assign("menu",$value);
$menu[] = $smarty->fetch("menu.html");
}
|
vielleicht wäre es sinnvoller das $links-array direkt im haupttemplate einzubauen? wahrscheinlich auch schneller. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|