TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 07-28-2009, 02:19 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default jQuery help

Heya!

I'm trying to make a menusystem that supports up to 2 submenus.
The PHP code looks like this:

php Code:
<ul id="menu">

    <?php foreach($this->links as $name => $value) :
   
    if(!is_array($value)) : ?>
       
    <li><a href="<?php echo $value; ?>"><?php echo $name; ?></a></li>
       
    <?php endif; if(is_array($value)) : ?>
       
        <ul class="sub">
       
        <?php foreach($value as $name => $subvalue) :
        if(!is_array($subvalue)) : ?>
       
            <li><a href="<?php echo $subvalue; ?>"><?php echo $name; ?></a></li>
                   
            <?php endif; if(is_array($subvalue)) : ?>
           
                <ul class="sub2">
               
                <?php foreach($subvalue as $name => $sub2value) : ?>
               
                    <li><a href="<?php echo $sub2value; ?>"><?php echo $name; ?></a></li>
                           
                <?php endforeach; ?>
               
                </ul>
                   
            <?php endif; endforeach; ?>
           
        </ul>
   
    <?php endif; endforeach; ?>

</ul>

I've set classes sub and sub2 to display: none in CSS.
What I want is that when the user clicks a link, the submenu that belongs to that link is rolled out.

The $links variable is an array with all the menus, and it's quite long, but here it is:
php Code:
<?php

    $links = array(
   
        'Senaste nytt' => 'latest.php',
        'Medlemmar' => 'members.php',
        'Verksamhet' => 'workshop.php',
        'SUB-Verksamhet' => array(
       
            'Allmänt' => 'general.php',
            'Stadgar' => 'stadgar.php',
            'Styrelse' => 'board.php',
            'SUB-Styrelse' => array(
           
                'Arbetsbeskrivningar' => 'workdetails.php',
                'Vilka ingår' => 'whosincluded.php',
                'Mallar och avtal' => 'blueprints.php'
           
            ),
            'Mötesprotokoll' => 'protocols.php',
            'SUB-Mötesprotokoll' => array(
           
                2009 => '2009.php',
                2008 => '2008.php',
                2007 => '2007.php',
                2006 => '2006.php'
           
            ),
            'Underhålls- och förnyelseplan' => 'plans.php',
            'SUB-Underhålls- och förnyelseplan' => array(
           
                'Aktuell version' => 'latest.php',
                'Tidigare versioner' => 'earlier.php'
           
            ),
            'Verksamhetsberättelser' => 'stories.php',
            'SUB-Verksamhetsberättelser' => array(
           
                2009 => '2009.php',
                2008 => '2008.php',
                2007 => '2007.php',
                2006 => '2006.php'
           
            ),
            'Revisionsberättelser' => 'revisions.php',
            'SUB-Revisionsberättelser' => array(
           
                2009 => '2009.php',
                2008 => '2008.php',
                2007 => '2007.php',
                2006 => '2006.php'
           
            ),
            'Motioner' => 'motions.php',
            'SUB-Motioners' => array(
           
                'Inskickade' => 'pending.php',
                'Avhandlade' => 'dealtwith.php',
                'Mejla till styrelsen' => 'email.php'
           
            )
       
        ),
        'Ekonomi' => 'economy.php',
        'SUB-Ekonomi' => array(
       
            'Aktuell avgift' => 'currently.php',
            2009 => '2009.php',
            2008 => '2008.php',
            2007 => '2007.php',
            2006 => '2006.php'
       
        ),
        'Arbetsgrupper' => 'workgroups.php',
        'SUB-Arbetsgrupper' => array(
       
            'Byggnadsgruppen' => 'build.php',
            'Trädgårdsgruppen' => 'garden.php',
            'Lekplatsgruppen' => 'playground.php',
            'Väg- och belysningsgruppen' => 'road.php'
       
        ),
        'Städdag' => 'cleaning.php',
        'SUB-Städdag' => array(
       
            'Nästa stadddag' => 'next.php',
            'Ansvarsområde' => 'responsibility.php',
            'Närvaro' => 'there.php'
       
        ),
        'Kvartersgården' => 'partyhouse.php',
        'SUB-Kvartersgården' => array(
       
            'Regler vid lån' => 'rules.php',
            'Bokning' => 'booking.php'
       
        ),
        'Cetralantenn' => 'central.php',
        'SUB-Centralantenn' => array(
       
            'Allmänt samt kanalinformation' => 'general.php',
            'Teknisk information' => 'technical.php'
       
        ),
        'Anslagstavlan' => 'messageboard.php',
        'Bildarkiv' => 'imagearchive.php',
        'Tidningsinsamling' => 'newspapercollector.php',
        'Länkar' => 'links.php'
   
    );

I didn't know any better way of marking the submenus than by putting the index to SUB-<nameoflinkitbelongsto>.

Don't know how I would proceed from here though to make the JS part work. Any tips or ideas would be appreciated!
__________________

Last edited by Wildhoney : 07-28-2009 at 03:34 PM.
Tanax is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with jQuery Hightower Javascript, AJAX, E4X 8 06-23-2009 08:16 PM
jQuery Timer Plugin ETbyrne The Lounge 0 06-14-2009 02:16 PM
jquery wont work for me :( sarmenhb Javascript, AJAX, E4X 2 09-27-2008 08:52 PM
Cookie issue -jQuery Sam Granger Javascript, AJAX, E4X 0 12-14-2007 01:44 PM


All times are GMT. The time now is 05:15 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design