Banshee
the secure PHP framework

Forum

Menu nesting

Andre
20 april 2011, 18:03

Banshee version: 3.1
PHP version: 5.3.4
MySQL version: 5.5.10
Webserver: hiawatha

When I add nested menu items, they don't populate on the website's output xml. I only get the first level menu items.
I get all levels however on the admin output xml. What do I need to do to get all levels populated on my site menu.

mysql> select * from menu;
+----+-----------+-------+----------+----------+
| id | parent_id | order | text | link |
+----+-----------+-------+----------+----------+
| 35 | 29 | 3 | service3 | /s3 |
| 34 | 29 | 2 | service2 | /s2 |
| 28 | 0 | 1 | about | /home |
| 29 | 0 | 2 | services | /service |
| 30 | 0 | 3 | contact | /contact |
| 31 | 28 | 1 | profile | /profile |
| 32 | 28 | 2 | why us | /why |
| 33 | 29 | 1 | service1 | /s1 |
+----+-----------+-------+----------+----------+


WEBSITE XML:
<?xml version="1.0" encoding="utf-8"?>
<output url="/home">
<banshee_version>3.1</banshee_version>
<website_url>10.1.1.15</website_url>
<page url="/home" module="home" type="">home</page>
<user id="1" admin="yes">Administrator</user>

<--only first level -->
<menu id="0">
<item id="28">
<link>/home</link>
<text>about</text>
</item>
<item id="29">
<link>/service</link>
<text>services</text>
</item>
<item id="30">
<link>/contact</link>
<text>contact</text>
</item>
</menu>
<--only first level -->

<content>
</content>
<layout_site>
<description>Secure PHP framework</description>
<keywords>banshee, secure, php, framework</keywords>
<title page=""></title>
<language>en</language>
<styles>
</styles>
<inline_css/>
<javascripts>
</javascripts>
<alternates>
</alternates>
</layout_site>
</output>


ADMIN SITE XML:
<?xml version="1.0" encoding="utf-8"?>
<output url="/admin/menu/29">
<banshee_version>3.1</banshee_version>
<website_url>10.1.1.15</website_url>
<page url="/admin/menu/29" module="admin/menu" type="">admin/menu</page>
<user id="1" admin="yes">Administrator</user>

<--all levels -->
<menu id="0">
<item id="28">
<link>/home</link>
<text>about</text>
</item>
<item id="29">
<link>/service</link>
<text>services</text>
</item>
<item id="30">
<link>/contact</link>
<text>contact</text>
</item>
</menu>
<content>
<edit>
<parent id="0">services</parent>
<menu id="29">
<item id="33">
<order>1</order>
<text>service1</text>
<link>/s1</link>
<children>0</children>
</item>
<item id="34">
<order>2</order>
<text>service2</text>
<link>/s2</link>
<children>0</children>
</item>
<item id="35">
<order>3</order>
<text>service3</text>
<link>/s3</link>
<children>0</children>
</item>
</menu>
<--all levels -->

<max_menu_id>36</max_menu_id>
</edit>
</content>
<layout_cms>
<description>Secure PHP framework</description>
<keywords>banshee, secure, php, framework</keywords>
<title page=""></title>
<language>en</language>
<styles>
<style>/css/admin/menu.css</style>
</styles>
<inline_css/>
<javascripts>
</javascripts>
<alternates>
</alternates>
</layout_cms>
</output>
Hugo Leisink
20 april 2011, 22:53
Both website and admin xml give you the same menu xml. Take a look again at it. The admin xml contains an extra menu tag, which is used to create the /admin page. It has nothing to do with the topbar menu.

If you want to show the menu submenus, change the "$menu->output(0)" in public/index.php to "$menu->output(0, 2)". The extra 2 is for depth 2 (see libraries/menu.php).
Andre
21 april 2011, 01:40
That's the info that I needed. Thanks.
René
26 april 2011, 22:30
Nice! Thanks.
Message preview

The following BB-codes are available in a message:

  • [b]Bold text[/b]
  • [center]Center text or imagen[/center]
  • [color=color name or #RGB code]Colored text[/color]
  • [i]Italic text[/i]
  • [img]Link to image[/img]
  • [right]Align text or image right[/right]
  • [s]Strike-through text[/s]
  • [size=pixelsize]Big or small text[/size]
  • [u]Underlined text[/u]
  • [url]Link to website[/url]
  • [url=link to website]Link text[/url]