Witam
jestem totalnie zielony w php wspolpracujacym z XML, ale przyszko mi zrobic menu. oto jego kod:
<?php
function __getActionMenu () {
$object = @simplexml_load_file('templates/'._defaultATpl.'/menu.xml') or debuger::throwMessage('Nie można podpiąć pliku obsługi menu! Skrypt kończy swoją pracę.', CRITICAL);
foreach ($object->menu as $menu) {
if($menu['link']=='?module='.$_GET['module'])
{
foreach($menu->cat as $firstChild) {
$this->result['content'] .= '
<div class="catBox">
<div class="catTitle">'.$firstChild['title'].'</div><div class="clear:both;"> </div>';
foreach($firstChild->menuElement as $secondChild) {
$this->result['content'] .= '
<div class="catElementBox">
<table style="font-size: 11px; vertical-align: middle;">
<tr><td><img src="'.$secondChild['img'].'" alt=" " /></td></tr>
<tr><td><a href="'.$secondChild['href'].'">'.$secondChild['title'].'</a></span></td></tr>
</table></div>';
}
$this->result['content'] .= '</div>';
}
}
}
}
?>
Sek w tym, ze ma on wybrac tylko raz kategoriw i elementy, a tymczasem wywala mi kilkakrotnie to samo. Oto struktura XML:
<?xml version="1.0" encoding="utf-8"?>
<document>
<menu
title="Zarządzanie zawartością"
icon="templates/_default/gfx/addedit.png"
link="?module=content">
<cat title="Zarządzanie nowościami">
<menuElement href="?module=content&action=addNews" title="Dodaj newsa" img="gfx/menu/small/document.png" />
<menuElement href="?module=content&action=menageNews" title="Zarządzaj newsami" img="gfx/menu/small/document.png" />
<menuElement href="?module=content&action=menageNewsCats" title="Zarządzaj kategoriami" img="gfx/menu/small/document.png" />
</cat>
<cat title="Zarządzanie nowościami">
<menuElement href="?module=content&action=menageArtsCats" title="Zarządzaj kategoriami" img="gfx/menu/small/document.png" />
<menuElement href="?module=content&action=menageArts" title="Zarządzaj artykułami" img="gfx/menu/small/document.png" />
<menuElement href="?module=content&action=addArt" title="Dodaj artykuł" img="gfx/menu/small/document.png" />
</cat>
</menu>
<menu
title="Zarzdzanie multimediami"
icon="templates/_default/gfx/mediamanager.png"
link="?module=media">
<cat title="Zarządzanie działem download">
<menuElement href="?module=media&action=addDownFile" title="Dodaj plik" img="gfx/menu/small/menu_ex.png" />
<menuElement href="?module=media&action=menageDownFiles" title="Zarządzaj plikami" img="gfx/menu/small/menu_ex.png" />
<menuElement href="?module=media&action=addDowCat" title="Dodaj kategorię" img="gfx/menu/small/menu_ex.png" />
<menuElement href="?module=media&action=menageDownCats" title="Zarządzaj kategoriami" img="gfx/menu/small/menu_ex.png" />
</cat>
<cat title="Zarządzanie skryptem galerii">
<menuElement href="?module=media&action=addPic" title="Dodaj zdjęcie" img="gfx/menu/small/menu_ex.png" />
<menuElement href="?module=media&action=menagePics" title="Zarządzaj zdjęciami" img="gfx/menu/small/menu_ex.png" />
<menuElement href="?module=media&action=addGalCat" title="Dodaj kategorię" img="gfx/menu/small/menu_ex.png" />
<menuElement href="?module=media&action=menageGalCats" title="Zarządzaj kategoriami" img="gfx/menu/small/menu_ex.png" />
</cat>
</menu>
</document>
Jak wybiera zarzadanie zawartoscia to jest ok, ale jak dam zarzadzanie multimediami to mi daje 2 razy ta sama kategorie.
Z gory dzieki za pomoc.
Rwvax.