parser

Post answer on current message

 

 
   search options

Universal nested levels lister

ShowMaster 23.09.2004 11:10 / 23.09.2004 11:11

Problem:

The database has got two major types of tables:

${section_name}_sub == section's subsections, where:
'idx' gives each subsection a unique id,
'parent' shows the parent subsection's 'idx',
'children' indicates if this subsection's got child subsections

${section_name} == section's pages (uri, title, etc. included)

The problem is to make a universal directory listing machine, that is the one that would check if a subdir has/hasn't any children and do different type of things. In the end it must be like:
<H1>LEVEL.1</H1>
  <H2>LEVEL.2</H2>
    <H3>LEVEL.3</H3>
      <UL>
      <A HREF="link.1">Link.1 text</A>
      <A HREF="link.2">Link.2 text</A>
      <A HREF="link.3">Link.3 text</A>
      <A HREF="link.4">Link.4 text</A>
      </UL>
  <H2>LEVEL.2</H2>
    <H3>LEVEL.3</H3>
      <H4>LEVEL.4</H4>
        <UL>
        <A HREF="link.1">Link.1 text</A>
        <A HREF="link.2">Link.2 text</A>
        <A HREF="link.3">Link.3 text</A>
        <A HREF="link.4">Link.4 text</A>
        </UL>
      <H4>LEVEL.4</H4>
        <UL>
        <A HREF="link.1">Link.1 text</A>
        <A HREF="link.2">Link.2 text</A>
        <A HREF="link.3">Link.3 text</A>
        <A HREF="link.4">Link.4 text</A>
        </UL>
...
The thing is that it must work however many nesting levels are present (that's what I mean by universal lister), so that I could just add new entries in ${section_name}_sub and ${section}. That is, I know that there must be some loop (even more than one), but still cannot get what loop to use and HOW...

  • Universal nested levels lister, ShowMaster 23.09.2004 11:10 / 23.09.2004 11:11