Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Design question…Is it even possible??? 
 
Reben002
Member
 
Total Posts:  41
Joined:  2009-02-13
 

Hello there people

I’ve been struggling with inserting of a specific JavaScript. Basically i want a dropdown listbox to replace my navigation bar and i’ve been fighting with it for weeks now........

I want to get this simple look

This is what I’ve done:

1. I written down the java function at js/varien/dropdownmeny.js

function dropdownmeny() {
var URL document.menyform.listmeny.options[document.menyform.listmeny.selectedIndex].value;

[removed].href URL}

2.  In the default\default\layout\page.xml i added

<action method="addJs">
  <
script>varien/dropdown.js</script> 
  
</action>
3. Now people is the tricky part. What shall i write in catalog\navigation\top.phtml

<form name="menyform">
<
select name="listmeny" onChange="dropdownmeny()">

<
option selected value="Choose">Choose</option>

[color=gray]// For each topcategory I want a Dropdown list with subcategories !![/color]

<option value=" //What kind of php forech should i write here then????// ">Ananas</option>


</
select>
</
form>

//And as i said before I want it to create a dropdown for each topcategory with subcategories

Is this even possible???????????????? :D

Image Attachments
pad.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
Reben002
Member
 
Total Posts:  41
Joined:  2009-02-13
 

Amazing LostDocs7 :D that script really worked flawless! And thanks for the other tips guys!

LostDocs7 or anyone, is it possible so add a special option class to the subcategories? I would bee perfect if they were more spaced to the right to make it more easy for the eye!

And if that’s possible, where should i put the subcategory option class in this script?

<?php 
function showCategory$current_category$object$is_subcat ){
    
if( !$current_category->getIsActive() ){
        
return;
    
}
    
if ($is_subcat == true){
        
echo '<option value="'.$object->getCategoryUrl$current_category ).'">' $object->htmlEscape$current_category->getName() ) . '</option>';
    
}
    else{
        
echo $object->htmlEscape$current_category->getName() ) . '<br>';
    
}        
    
if ( ( $children $current_category->getChildren() ) && $children->count() ){
        
if ($is_subcat == false){
            
echo '<select>';
        
}
        
foreach ( $children as $child_category){
                showCategory
$child_category$objecttrue );
            
}
        
if ($is_subcat == false){
            
echo '</select><br><br>';
        
}
    }
}
$_categories
=$this->getStoreCategories();
foreach (
$_categories as $category){
    showCategory
$category$thisfalse );
}
?>

This is what I ultimatly want to acheive

Image Attachments
padning.JPG
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top