Jump to content

building a dynamic drop down menu...


acsonline

Recommended Posts

Hey Guys,

 

I'm building a site and I need a drop down menu created dynamicly....

 

This is the flat html code

<div class="art-nav">
            	<div class="l"></div>
            	<div class="r"></div>
            	<ul class="art-menu">
<li><a href="URL 1"><span class="l"></span><span class="r"></span><span class="t">TOP LEVEL</span></a>
<ul>
<li><a href="URL 1">SUB CAT 1</a></li>
<li><a href="URL 2">SUB CAT 2</a></li>
<li><a href="URL 3">SUB CAT 3</a></li>
</ul>
</li>

<li class="art-menu-li-separator"><span class="art-menu-separator"></span></li>
<li><a href="URL 5"><span class="l"></span><span class="r"></span><span class="t">Contact Us</span></a></li>
            	</ul>
            </div>

 

This is the code that shows a dyamic code, but not in the menu...

 

<?php wpsc_start_category_query(array('category_group'=> get_option('wpsc_default_category'), 'show_thumbnails'=> get_option('show_category_thumbnails'))); ?>
<a href="<?php wpsc_print_category_url();?>" class="wpsc_category_link"><?php wpsc_print_category_name();?></a> |
<?php wpsc_print_subcategory(); ?>
<?php wpsc_end_category_query(); ?>

Link to comment
https://forums.phpfreaks.com/topic/229494-building-a-dynamic-drop-down-menu/
Share on other sites

ok, couple of things - you know you don't need to open and close every line of php code with <?php ?> right?, also, where are you populating your array from?  is it hard coded into the page (cause if it is it's still not "dynamic", it's just a more complicated way of doing what's already done in html)?

ah this is generated from a wordpress site, so taken from the DB... :)

 

I do, but for some reason I just feel safer adding it lol :)

 

This is the code I've now edited, but the trouble I am having is generating the drop downs for the sub categories

 

<div class="art-nav">
            	<div class="l"></div>
            	<div class="r"></div>
            	<ul class="art-menu">

<?php wpsc_start_category_query(array('category_group'=> get_option('wpsc_default_category'), 'show_thumbnails'=> get_option('show_category_thumbnails'))); ?>

	<?php //wpsc_print_subcategory(); ?>

<li><a href="<?php wpsc_print_category_url();?>"><span class="l"></span><span class="r"></span><span class="t"><?php wpsc_print_category_name();?></a></span></a></li>
<li class="art-menu-li-separator"><span class="art-menu-separator"></span></li>

    <?php wpsc_end_category_query(); ?>
    </ul>
    </div>

 

This code: < ?php wpsc_print_subcategory(); ?> can have html attributes added to it, ie. < ?php wpsc_print_subcategory("<ul>", ""); ?> however I'm not 100% sure how to code the attributes..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.