|
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 |
blackfire49 Smarty n00b
Joined: 02 Sep 2018 Posts: 2
|
Posted: Sun Sep 02, 2018 12:50 am Post subject: Menu mit smarty |
|
|
Guten Tag
Benötige eure hilfe ich hänge zur Zeit an meinem Menü fest
Ich hole mir Kategorie und Links aus 2 Tabellen diese speichere ich in einem Array das am ende ungefähr so aus sieht
Quote: |
Array
(
[1] => Array
(
[title] => Array
(
[0] => Menu
[1] => Clan Menu
)
[link] => Array
(
[Menu] => Array
(
[0] => downloads
[1] => links
)
[Clan Menu] => Array
(
[0] => teams
[1] => squad
)
)
)
[2] => Array
(
[title] => Array
(
[0] => Login
)
[link] => Array
(
[Login] => Array
(
[0] => login
)
)
)
)
|
Wo Array 1 für das Linke Menü steht und Array 2 für das Rechte
So dieses Array sende ich als data an mein Template
jetzt soll es natürlich so aussehn
Quote: |
Menu
- News
- Downloads
- Links
Clan Menu
- Teams
- Fight Us
- Join Us
|
aber Leider sieht es so aus
Quote: |
Menu
Clan Menu
- Downloads
- Links
|
gut hängt zur Zeit daran das ich zum test erstmal nur die Links vom Menu
anzeigen lasse aber ok.
Hier das Template
Code: |
{$x = null}
{$i = 0}
<ul>
{foreach $data as $item}
{if $data[1]['title'] !== $x}
{for $n = 0 to $countTitle_1 - 1}
<li>{$data[1]['title'][{$n}]}</li>
{$x = $data[1]['title']}
{/for}
{/if}
<li>{$data[1]['link']['Menu'][{$i}]}</li>
{$i = $i + 1}
{/foreach}
</ul>
|
Nun frage ich mich wie ich es umsetzten könne mein vorhaben umzusetzen
Hoffe ihr könnt mir dabei helfen. |
|
Back to top |
|
Grizzly Smarty Pro
Joined: 15 Apr 2011 Posts: 172 Location: Germany
|
Posted: Mon Sep 03, 2018 6:16 am Post subject: |
|
|
Warum machst du das denn allgemein so kompliziert?
Du solltest vielleicht lieber dein Array so aufbauen dass du immer pro Eintrag den Titel und Link hast und dann eben die "Kindknoten"
also so
Code: |
Array(
[0] => Array("title" => "Title 1",
"link" => "http..",
"children" => Array(
[0] =>Array("title" => "Sub Title 1", "link" => "http..")
[1] =>Array("title" => "Sub Title 2", "link" => "http.."))
)
|
Das ist doch dann um einiges leichter...
Aber ich denke dein Problem aktuell ist, dass du deinen Code:
Code: |
<li>{$data[1]['link']['Menu'][{$i}]}</li>
{$i = $i + 1}
|
IN die For-Schleife tun musst |
|
Back to top |
|
blackfire49 Smarty n00b
Joined: 02 Sep 2018 Posts: 2
|
Posted: Mon Sep 03, 2018 11:17 am Post subject: |
|
|
Stimmt natürlich die Methode ist kompliziert muss ich ändern
Und bin schon an überlegen wie ich es anders machen könnte damit ich
Keine for schleife nutzen muss |
|
Back to top |
|
Grizzly Smarty Pro
Joined: 15 Apr 2011 Posts: 172 Location: Germany
|
|
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
|