[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] PHP flerdimensionel array "udfordring".



>
> On 13/04/2010, at 21.26, Jesper K. Pedersen wrote:
>
>> I forbindelse med et lille projekt jeg er i gang med, har jeg
>> forestillet mig at bruge et flerdimensionelt array til at styre
>> menu-generering.
> Jeg har haft stor succes med at gøre det via klasser i stedet for arrays.
> f.eks. med en klasse MenuNode. Den har en parent() funktion, der
> returnerer en MenuNode til det overliggende punkt eller null, hvis der
> ikke er en overliggende.
> Derudover har den en children() funktion, der returnerer et array af
> MenuNodes. Det kan selvfølgelig være et tomt array hvis der ikke er nogen
> children. Da jeg ikke ved, hvordan du gemmer dine menuer, er det svært at
> sige, hvodan disse funktioner skal skrives.
>
> Nu kan din BreadCrumb laves som:
> $currentNode = ... den node, du har lavet ud fra at du ved, det f.eks. er
> FilmOversigt, der er valgt.
[klip]

Jeg endte op med at lave det via en klasse hvor jeg "snød" lidt.
Mit snyd bestod i af jeg parsede mit oprindelige array, som var den
"letlæsbare" menu-struktur til en flad struktur, som var let at søge
igennem.

Det gjorde det også lettere at fjerne/skjule/tilføje menuer efter behov.

Men tak for detaljerne til et løsningsforslag.

Mvh
  JesperKP


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2010-07-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *