SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 49 of 49
  1. #26
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    PHP Code:
    function makeMenu($pages) {

        echo 
    '<ul>',"\n";
        foreach(
    $pages as $page) {
            
            
    $file $page->getFile();
            if(empty(
    $file)) {
                echo 
    '<li id="',str_replace(' ','-',strtolower($page->getTitle())),'">',$page->getTitle();
            } else {
                echo 
    '<li id="',str_replace(' ','-',strtolower($page->getTitle())),'"><a href="',$file,'">',$page->getTitle(),'</a>';
            }
        
            
    $childPages $page->getPages();
            if(!empty(
    $childPages)) makemenu($childPages);
        
            echo 
    '</li>',"\n";

        }
        echo 
    '</ul>',"\n";


    Replace the previous makeMenu function with this new one and all should be good.

  2. #27
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks for this oddz, think we're almost there

    Only slight issue is that my HTML should look like the following:

    HTML Code:
    <ul id="nav">
    			<li id="contact">
    				<a href="/contact/">contact</a>
    
    				<a class="tab" href="/contact/"></a>
    				<div class="callout" id="contacttab">
    					<div class="bg"></div>
    					<div class="aCol">
    				
    					<ul>
    						<li><a href="#">Rooms</a>		
    						<li><a href="#">Business</a></li>
    					</ul>
    				</div>
    
    				</div>
    			</li>
    
    			
    			<li id="contact2">
    				<a href="/contact2/">contact</a>
    
    				<a class="tab" href="/contact2/"></a>
    				<div class="callout" id="contact2tab">
    					<div class="bg"></div>
    					<div class="aCol">
    				
    					<ul>
    						<li><a href="#">Rooms 2</a>		
    						<li><a href="#">Business 2</a></li>
    					</ul>
    				</div>
    
    				</div>
    			</li>
    </ul>
    But it seems to come out as:

    HTML Code:
    <ul id="nav">
    
    <ul>
    
    			<li id="contact">
    				<a href="/contact/">contact</a>
    				
    					<ul>
    						<li><a href="#">Rooms</a>		
    						<li><a href="#">Business</a></li>
    					</ul>
    
    			</li>
    
    			
    			<li id="contact2">
    				<a href="/contact2/">contact</a>
    				
    					<ul>
    						<li><a href="#">Rooms 2</a>		
    						<li><a href="#">Business 2</a></li>
    					</ul>
    
    			</li>
    </ul>
    
    </ul>
    Really apologise for the extra bits here, you've been a huuuuge help so far.

    Can you show me the best way to display it like the first set of HTML above.


    Many thanks.

  3. #28
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    hmmm…

    I'll take a look at it, but its apparently incorrect. The closing li tag isn't being added either.

    Notice where is says Rooms 2. After the end anchor tag there should be a closing li tag unless that item has children.

    HTML Code:
    			<li id="contact2">
    				<a href="/contact2/">contact</a>
    				
    					<ul>
    						<li><a href="#">Rooms 2</a>		
    						<li><a href="#">Business 2</a></li>
    					</ul>
    
    			</li>

  4. #29
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks for the reply Oddz.

    Oh, my apologies. I typed it in rather quickly and forgot to add that.

    Here's the corrected code that I am hoping to generate.....

    HTML Code:
    <ul id="nav">
    			<li id="contact">
    				<a href="/contact/">contact</a>
    
    				<a class="tab" href="/contact/"></a>
    				<div class="callout" id="contacttab">
    					<div class="bg"></div>
    					<div class="aCol">
    				
    					<ul>
    						<li><a href="#">Rooms</a></li>	
    						<li><a href="#">Business</a></li>
    					</ul>
    				</div>
    
    				</div>
    			</li>
    
    			
    			<li id="contact2">
    				<a href="/contact2/">contact</a>
    
    				<a class="tab" href="/contact2/"></a>
    				<div class="callout" id="contact2tab">
    					<div class="bg"></div>
    					<div class="aCol">
    				
    					<ul>
    						<li><a href="#">Rooms 2</a></li>		
    						<li><a href="#">Business 2</a></li>
    					</ul>
    				</div>
    
    				</div>
    			</li>
    </ul>
    Again sorry for all the messing about. I was trying to make it easier, but ended up making it more complex

  5. #30
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    That makes sense. I was testing it on my local and everything seemed to be working correctly. What level/depth do need those extra divisions? Do you need them to wrap around every unordered list element?

  6. #31
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again Oddz.

    Yes, the <div>'s will wrap around the first-level UL's.

    So, a more complete example would be:

    HTML Code:
    <ul id="nav">
    			<li id="contact">
    				<a href="/contact/">contact</a>
    
    				<a class="tab" href="/contact/"></a>
    				<div class="callout" id="contacttab">
    					<div class="bg"></div>
    					<div class="aCol">
    				
    					<ul>
    						<li><a href="#">Rooms</a>
    						 <ul><li><a href="#">Subpage of Rooms</a></li></ul>
    						</li>	
    						<li><a href="#">Business</a></li>
    					</ul>
    				</div>
    
    				</div>
    			</li>
    
    			
    			<li id="contact2">
    				<a href="/contact2/">contact</a>
    
    				<a class="tab" href="/contact2/"></a>
    				<div class="callout" id="contact2tab">
    					<div class="bg"></div>
    					<div class="aCol">
    				
    					<ul>
    						<li><a href="#">Rooms</a>
    						 <ul><li><a href="#">Subpage of Rooms 2</a></li></ul>
    						</li>		
    						<li><a href="#">Business 2</a></li>
    					</ul>
    				</div>
    
    				</div>
    			</li>
    </ul>
    I don't expect it to go down any further levels in the hierarchy.

    Really appreciate your patience and help with this, I'd be lost without it

  7. #32
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    ?

    PHP Code:
    function makeMenu($pages,$runner=0) {

        echo 
    '<ul>',"\n";
        foreach(
    $pages as $key=>$page) {
            
            
    $file $page->getFile();
            if(empty(
    $file)) {
                echo 
    '<li id="',str_replace(' ','-',strtolower($page->getTitle())),'">',$page->getTitle();
            } else {
                echo 
    '<li id="',str_replace(' ','-',strtolower($page->getTitle())),'"><a href="',$file,'">',$page->getTitle(),'</a>';
            }
            
            if(
    $runner==0) {
            
            
    $label str_replace(' ','-',strtolower($page->getTitle())).$key;
            echo 
    '<a class="tab" href="/',$label,'/"></a>',"\n";
            echo 
    '<div class="callout" id="',$label,'tab">',"\n",'<div class="bg"></div>',"\n",'div class="aCol">',"\n";
            
            }
        
            
    $childPages $page->getPages();
            if(!empty(
    $childPages)) makemenu($childPages,($runner+1));
            
            if(
    $runner==0) echo '</div>',"\n",'</div>',"\n";
            
            echo 
    '</li>',"\n";

        }
        echo 
    '</ul>',"\n";



  8. #33
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your persistence again.

    Think we're almost there.

    There seems to be just 3 issues remaining.

    1) Is there anyway to call the first <ul> (which contains the entire set of lists) <ul id="nav"> ? There is only 1 instance of this.
    So it'd be like:

    HTML Code:
    <ul id="nav">
    <li id="contact">
    				<a href="/contact/">contact</a>
    
    				<a class="tab" href="/contact/"></a>
    				<div class="callout" id="contacttab">
    					<div class="bg"></div>
    					<div class="aCol">
    				
    					<ul>
    						<li><a href="#">Rooms</a>
    						 <ul><li><a href="#">Subpage of Rooms</a></li></ul>
    						</li>	
    						<li><a href="#">Business</a></li>
    					</ul>
    				</div>
    
    				</div>
    			</li>
    
    			
    			<li id="contact2">
    				<a href="/contact2/">contact</a>
    
    				<a class="tab" href="/contact2/"></a>
    				<div class="callout" id="contact2tab">
    					<div class="bg"></div>
    					<div class="aCol">
    				
    					<ul>
    						<li><a href="#">Rooms</a>
    						 <ul><li><a href="#">Subpage of Rooms 2</a></li></ul>
    						</li>		
    						<li><a href="#">Business 2</a></li>
    					</ul>
    				</div>
    
    				</div>
    			</li>
    </ul>

    Thanks so much again for your help with this.

  9. #34
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    PHP Code:
    function makeMenu($pages,$runner=0) {
        
        
    $navId $runner==0?' id ="nav"':'';
        echo 
    '<ul',$navId,'>',"\n";
        foreach(
    $pages as $key=>$page) {
            
            
    $file $page->getFile();
            if(empty(
    $file)) {
                echo 
    '<li id="',str_replace(' ','-',strtolower($page->getTitle())),'">',$page->getTitle();
            } else {
                echo 
    '<li id="',str_replace(' ','-',strtolower($page->getTitle())),'"><a href="',$file,'">',$page->getTitle(),'</a>';
            }
            
            if(
    $runner==0) {
            
            
    $label str_replace(' ','-',strtolower($page->getTitle())).$key;
            echo 
    '<a class="tab" href="/',$label,'/"></a>',"\n";
            echo 
    '<div class="callout" id="',$label,'tab">',"\n",'<div class="bg"></div>',"\n",'div class="aCol">',"\n";
            
            }
        
            
    $childPages $page->getPages();
            if(!empty(
    $childPages)) makemenu($childPages,($runner+1));
            
            if(
    $runner==0) echo '</div>',"\n",'</div>',"\n";
            
            echo 
    '</li>',"\n";

        }
        echo 
    '</ul>',"\n";



  10. #35
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    edit

    Think we're almost there.

    Be back in 5mins

  11. #36
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, think we're 95&#37; of the way there.
    Sir if you were in the UK, I'd drive and buy a very large pint(for you) at this point.

    Only tiny we issue I have is with my sub-pages.

    It displays it like the following

    HTML Code:
    <div class="callout" id="contacttab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="special-occasions"><a href="contact/special-occasions/index.php">Special Occasions</a></li>
    <li id="weddings"><a href="contact/weddings/index.php">Weddings</a></li>
    <li id="planner"><a href="contact/weddings/planner.php">Planner</a><ul>
    <li id="weddings"><a href="contact/weddings/index.php">Weddings</a></li>
    </ul>
    </li>
    <li id="ceremony-reception"><a href="contact/weddings/ceremony-reception.php">Ceremony &amp; reception</a><ul>
    
    <li id="weddings"><a href="contact/weddings/index.php">Weddings</a></li>
    </ul>
    </li>
    <li id="catering"><a href="contact/weddings/catering.php">Catering</a><ul>
    <li id="weddings"><a href="contact/weddings/index.php">Weddings</a></li>
    </ul>
    </li>
    <li id="contact"><a href="contact">contact</a></li>
    </ul>
    </div>
    </div>
    When it should really be like this

    HTML Code:
    <div class="callout" id="contacttab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="special-occasions"><a href="contact/special-occasions/index.php">Special Occasions</a></li>
    <li id="weddings"><a href="contact/weddings/index.php">Weddings</a>
    <ul>
    <li id="planner"><a href="contact/weddings/planner.php">Planner</a></li>
    <li id="ceremony-reception"><a href="contact/weddings/ceremony-reception.php">Ceremony &amp; reception</a><ul>
    <li id="catering"><a href="contact/weddings/catering.php">Catering</a><ul>
    </ul>
    </li>
    </div>
    </div>

  12. #37
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Oddz,

    Can you possible take a quick look at this if you get a chance?

    Super appreciate the help and time you've given so far to it.

  13. #38
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    hmmm…

    Could you post the HTML output for the entire menu. Then also post the entire menu structured as you need it. If you could do this with the original data expressed in the first post that would help me better understand everything also.

  14. #39
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Oddz,

    Thanks again.

    This is what is outputted using your PHP code so far:

    HTML Code:
    <ul id ="nav">
    
    <li id="stay"><a href="/stay/">stay</a>
    <a class="tab" href="/stay/"></a>
    <div class="callout" id="staytab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="bedrooms"><a href="stay/bedrooms/index.php">Bedrooms</a></li>
    <li id="stay"><a href="stay/">Stay</a></li>
    </ul>
    </div>
    </div>
    </li>
    <li id="play"><a href="/play/">play</a>
    
    <a class="tab" href="/play/"></a>
    <div class="callout" id="playtab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="local-area"><a href="play/local-area/index.php">Local Area</a></li>
    <li id="shopping"><a href="play/shopping/index.php">Shopping</a></li>
    <li id="health-club"><a href="play/health-club/index.php">Health Club</a></li>
    <li id="play"><a href="play/">Play</a></li>
    
    </ul>
    </div>
    </div>
    </li>
    <li id="eat"><a href="/eat/">eat</a>
    <a class="tab" href="/eat/"></a>
    <div class="callout" id="eattab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="restaurants"><a href="eat/restaurants/index.php">Restaurants</a></li>
    <li id="menus"><a href="eat/menus/index.php">Menus</a></li>
    <li id="eat"><a href="eat/">Eat</a></li>
    </ul>
    </div>
    </div>
    </li>
    <li id="meet"><a href="/meet/">meet</a>
    <a class="tab" href="/meet/"></a>
    <div class="callout" id="meettab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    
    <li id="conferences"><a href="meet/conferences/index.php">Conferences</a></li>
    <li id="rooms"><a href="meet/rooms/index.php">Rooms</a></li>
    <li id="meet"><a href="meet/">Meet</a></li>
    </ul>
    </div>
    </div>
    </li>
    <li id="celebrate"><a href="/celebrate/">celebrate</a>
    
    <a class="tab" href="/celebrate/"></a>
    <div class="callout" id="celebratetab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="special-occasions"><a href="celebrate/special-occasions/index.php">Special Occasions</a></li>
    <li id="weddings"><a href="celebrate/weddings/index.php">Weddings</a></li>
    <li id="planner"><a href="celebrate/weddings/planner.php">Planner</a>
    <ul>
    <li id="weddings"><a href="celebrate/weddings/index.php">Weddings</a></li>
    </ul>
    </li>
    <li id="ceremony-&amp;-reception"><a href="celebrate/weddings/ceremony-reception.php">Ceremony &amp; reception</a>
    <ul>
    <li id="weddings"><a href="celebrate/weddings/index.php">Weddings</a></li>
    </ul>
    </li>
    <li id="catering"><a href="celebrate/weddings/catering.php">Catering</a>
    <ul>
    <li id="weddings"><a href="celebrate/weddings/index.php">Weddings</a></li>
    </ul>
    </li>
    <li id="celebrate"><a href="celebrate">Celebrate</a></li>
    </ul>
    </div>
    </div>
    </li>
    <li id="location"><a href="/location/">location</a>
    
    <a class="tab" href="/location/"></a>
    <div class="callout" id="locationtab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="location"><a href="location/index.php">Location</a></li>
    </ul>
    </div>
    </div>
    </li>
    <li id="about-us"><a href="/about-us/">about-us</a>
    <a class="tab" href="/about-us/"></a>
    <div class="callout" id="about-ustab">
    <div class="bg"></div>
    <div class="aCol">
    
    <ul>
    <li id="awards"><a href="about-us/awards/index.php">Awards</a></li>
    <li id="privacy-policy"><a href="about-us/privacy-policy/index.php">Privacy Policy</a></li>
    <li id="careers"><a href="about-us/careers/index.php">Careers</a></li>
    <li id="links"><a href="about-us/links/index.php">Links</a></li>
    
    <li id="about-us"><a href="about-us/">About us</a></li>
    </ul>
    </div>
    </div>
    </li>
    </ul>
    And this is the exact HTML code I need:

    HTML Code:
    <ul id ="nav">
    
    <li id="stay"><a href="/stay/">stay</a>
    <a class="tab" href="/stay/"></a>
    <div class="callout" id="staytab">
    <div class="bg"></div>
    <div class="aCol">
    
    <ul>
    <li id="bedrooms"><a href="stay/bedrooms/index.php">Bedrooms</a></li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="play"><a href="/play/">play</a>
    <a class="tab" href="/play/"></a>
    <div class="callout" id="playtab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="local-area"><a href="play/local-area/index.php">Local Area</a></li>
    <li id="shopping"><a href="play/shopping/index.php">Shopping</a></li>
    <li id="health-club"><a href="play/health-club/index.php">Health Club</a></li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="eat"><a href="/eat/">eat</a>
    <a class="tab" href="/eat/"></a>
    <div class="callout" id="eattab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="restaurants"><a href="eat/restaurants/index.php">Restaurants</a></li>
    <li id="menus"><a href="eat/menus/index.php">Menus</a></li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="meet"><a href="/meet/">meet</a>
    <a class="tab" href="/meet/"></a>
    <div class="callout" id="meettab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="conferences"><a href="meet/conferences/index.php">Conferences</a></li>
    <li id="rooms"><a href="meet/rooms/index.php">Rooms</a></li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="celebrate"><a href="/celebrate/">celebrate</a>
    <a class="tab" href="/celebrate/"></a>
    <div class="callout" id="celebratetab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="special-occasions"><a href="celebrate/special-occasions/index.php">Special Occasions</a></li>
    <li id="weddings"><a href="celebrate/weddings/index.php">Weddings</a>
    <ul>
    <li id="planner"><a href="celebrate/weddings/planner.php">Planner</a></li>
    <li id="ceremony-&amp;-reception"><a href="celebrate/weddings/ceremony-reception.php">Ceremony &amp; reception</a></li>
    <li id="catering"><a href="celebrate/weddings/catering.php">Catering</a></li>
    </ul>
    </li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="location"><a href="/location/">location</a>
    <a class="tab" href="/location/"></a>
    
    <div class="callout" id="locationtab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="location"><a href="location/index.php">Location</a></li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="about-us"><a href="/about-us/">about-us</a>
    <a class="tab" href="/about-us/"></a>
    <div class="callout" id="about-ustab">
    <div class="bg"></div>
    <div class="aCol">
    
    <ul>
    <li id="awards"><a href="about-us/awards/index.php">Awards</a></li>
    <li id="privacy-policy"><a href="about-us/privacy-policy/index.php">Privacy Policy</a></li>
    <li id="careers"><a href="about-us/careers/index.php">Careers</a></li>
    <li id="links"><a href="about-us/links/index.php">Links</a></li>
    </ul>
    </div>
    </div>
    </li>
    </ul>
    Thanks again for your help with this, is there anything extra you need from me?

    As you can see the only remaining glitch is the strange thing that happens with the sub-pages(e.g. weddings should break down like.......

    weddings
    - planner
    - ceremony and reception
    - catering

    but right now it does:

    weddings
    - planner
    - weddings
    - ceremony - reception
    - weddings
    - catering
    - weddings


    Thanks again for any help with this.

  15. #40
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Oh… you just need the tab for the second level. In that case the below should work. If the runner is equal to the second level the extra HTML is outputted. Otherwise it is not. I think that is what your after.

    PHP Code:
    function makeMenu($pages,$runner=0) {
        
        
    $navId $runner==0?' id ="nav"':'';
        echo 
    '<ul',$navId,'>',"\n";
        foreach(
    $pages as $key=>$page) {
            
            
    $file $page->getFile();
            if(empty(
    $file)) {
                echo 
    '<li id="',str_replace(' ','-',strtolower($page->getTitle())),'">',$page->getTitle();
            } else {
                echo 
    '<li id="',str_replace(' ','-',strtolower($page->getTitle())),'"><a href="',$file,'">',$page->getTitle(),'</a>';
            }
            
            if(
    $runner==1) {
            
            
    $label str_replace(' ','-',strtolower($page->getTitle())).$key;
            echo 
    '<a class="tab" href="/',$label,'/"></a>',"\n";
            echo 
    '<div class="callout" id="',$label,'tab">',"\n",'<div class="bg"></div>',"\n",'div class="aCol">',"\n";
            
            }
        
            
    $childPages $page->getPages();
            if(!empty(
    $childPages)) makemenu($childPages,($runner+1));
            
            if(
    $runner==1) echo '</div>',"\n",'</div>',"\n";
            
            echo 
    '</li>',"\n";

        }
        echo 
    '</ul>',"\n";



  16. #41
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Oddz,

    I'm afraid that hasn't fixed the issue.

    It seems to have added tabs for all pages

    I'm just looking for it to work so the final HTML is like the 2nd lot I've posted above.

    So if it goes to a subpage that <li>bla</li> is broken into <li>bla<ul><li>bla 2</li></ul></li>

  17. #42
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basically this is exactly how the final code should look:


    HTML Code:
    <ul id ="nav">
    
    <li id="stay"><a href="/stay/">stay</a>
    <a class="tab" href="/stay/"></a>
    <div class="callout" id="staytab">
    <div class="bg"></div>
    <div class="aCol">
    
    <ul>
    <li id="bedrooms"><a href="stay/bedrooms/index.php">Bedrooms</a></li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="play"><a href="/play/">play</a>
    <a class="tab" href="/play/"></a>
    <div class="callout" id="playtab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="local-area"><a href="play/local-area/index.php">Local Area</a></li>
    <li id="shopping"><a href="play/shopping/index.php">Shopping</a></li>
    <li id="health-club"><a href="play/health-club/index.php">Health Club</a></li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="eat"><a href="/eat/">eat</a>
    <a class="tab" href="/eat/"></a>
    <div class="callout" id="eattab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="restaurants"><a href="eat/restaurants/index.php">Restaurants</a></li>
    <li id="menus"><a href="eat/menus/index.php">Menus</a></li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="meet"><a href="/meet/">meet</a>
    <a class="tab" href="/meet/"></a>
    <div class="callout" id="meettab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="conferences"><a href="meet/conferences/index.php">Conferences</a></li>
    <li id="rooms"><a href="meet/rooms/index.php">Rooms</a></li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="celebrate"><a href="/celebrate/">celebrate</a>
    <a class="tab" href="/celebrate/"></a>
    <div class="callout" id="celebratetab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="special-occasions"><a href="celebrate/special-occasions/index.php">Special Occasions</a></li>
    <li id="weddings"><a href="celebrate/weddings/index.php">Weddings</a>
    <ul>
    <li id="planner"><a href="celebrate/weddings/planner.php">Planner</a></li>
    <li id="ceremony-&amp;-reception"><a href="celebrate/weddings/ceremony-reception.php">Ceremony &amp; reception</a></li>
    <li id="catering"><a href="celebrate/weddings/catering.php">Catering</a></li>
    </ul>
    </li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="location"><a href="/location/">location</a>
    <a class="tab" href="/location/"></a>
    
    <div class="callout" id="locationtab">
    <div class="bg"></div>
    <div class="aCol">
    <ul>
    <li id="location"><a href="location/index.php">Location</a></li>
    </ul>
    </div>
    </div>
    </li>
    
    <li id="about-us"><a href="/about-us/">about-us</a>
    <a class="tab" href="/about-us/"></a>
    <div class="callout" id="about-ustab">
    <div class="bg"></div>
    <div class="aCol">
    
    <ul>
    <li id="awards"><a href="about-us/awards/index.php">Awards</a></li>
    <li id="privacy-policy"><a href="about-us/privacy-policy/index.php">Privacy Policy</a></li>
    <li id="careers"><a href="about-us/careers/index.php">Careers</a></li>
    <li id="links"><a href="about-us/links/index.php">Links</a></li>
    </ul>
    </div>
    </div>
    </li>
    </ul>

    Just for a reminder, my sql tables are like the following:

    bweb_cat:
    id | name
    0 | home
    1 | contact


    bweb_pages
    id | title | file_name | subcat | cat*

    0 | home page | index | 0 | 0
    1 | get in touch | get-in-touch | 0 | 1
    2 | guestbook | guestbook | 0 | 1
    3 | feedback | feedback | 0 | 1
    4 | further feedback | further-feedback | 3 | 1

  18. #43
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Oddz, did you manage to have another look at this?


    Thank you.

  19. #44
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    I've been a bit busy. I'll try to take a look at it within a few hours for you. Maybe someone else will be able to come around in that time though who will be able to resolve the issue.

  20. #45
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problems, completely understand.
    I tried it myself, but ended up giving myself a minor migraine heh.

    Thanks for looking again, super-appreciate it.

  21. #46
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Could you possibly post a dump of that array with all the data in it so I can use the test data?

    PHP Code:
    $rows = array();
    while(
    $row mysql_fetch_assoc($result)) $rows[] = $row;
    echo 
    '<pre>',print_r($row),'</pre>';  // <--  output of this 

  22. #47
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Oddz,

    Thanks for the reply.

    I've just this minute found a solution. I can post if you wish, although it doesn't use your OOP method(sadly).

    Thanks again for all your assistance with this, really appreciate it. And got me in the mood to do some of my own OOP.

  23. #48
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    PHP Code:
    <?php
    function makeMenu($pages,$runner=0) {
        
        
    $navId $runner==0?' id ="nav"':'';
        echo 
    "\n",str_repeat("\t",($runner+1)),'<ul',$navId,'>',"\n";
        foreach(
    $pages as $key=>$page) {
            
            
    $file $page->getFile();
            if(empty(
    $file)) {
                echo 
    str_repeat("\t",($runner+1)),'<li id="',str_replace(' ','-',strtolower($page->getTitle())),'"><a href="/',$page->getTitle(),'/">',$page->getTitle(),'</a>',"\n";
            } else {
                echo 
    str_repeat("\t",($runner+1)),'<li id="',str_replace(' ','-',strtolower($page->getTitle())),'"><a href="',$file,'">',$page->getTitle(),'</a>',"\n";
            }
            
            if(
    $runner==0) {
            
            
    $label str_replace(' ','-',strtolower($page->getTitle()));
            echo 
    str_repeat("\t",($runner+2)),'<a class="tab" href="/',$label,'/"></a>',"\n";
            echo 
    str_repeat("\t",($runner+2)),'<div class="callout" id="',$label,'tab">',"\n",str_repeat("\t",($runner+3)),'<div class="bg"></div>',"\n",str_repeat("\t",($runner+3)),'<div class="aCol">',"\n";
            
            }
        
            
    $childPages $page->getPages();
            if(!empty(
    $childPages)) makemenu($childPages,($runner+1));
            
            if(
    $runner==0) echo str_repeat("\t",($runner+3)),'</div>',"\n",str_repeat("\t",($runner+2)),'</div>',"\n";
            
            echo 
    str_repeat("\t",($runner+1)),'</li>',"\n";

        }
        echo 
    str_repeat("\t",$runner),'</ul>',"\n";

    }
    ?>

  24. #49
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,135
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Glad you got it all sorted out. You could post it for reference if you like. I'm sure someone else may come around with a similar problem.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •