Hello,

I created an dynamic drop down menu with prototype and scriptaculous.
It's working fine but there is a little problem. If an topcategory
doesn't have an subcategory (subcategories) the topcategory-link has
to link to an /controller/action and I don't need an <div>-Element.

Topcategory with subcategories:

Topitem
    <div id="subitems">
        Subitem 1 (-> link to /controller/action/subitem1_id)
        Subitem 2 (-> link to /controller/action/subitem2_id)
        Subitem 3 (-> link to /controller/action/subitem3_id)
    </div>


Topcategory with subcategories:

Topitem (-> link to /controller/action/topitem1_id)


I hope it's a little bit understandable and here is the code:

<!-- get top categories -->
<?php $categories = $this->requestAction('/categories/
getTopCategories'); ?>

<!-- generate menu -->
<ul id="mainmenu">
<?php foreach ($categories as $category): ?>
        <li id="topitems">
        <?php
                $options = array(
                                'url' => array(
                                                'controller' => 'categories',
                                                'action'         => 
'getSubCategoriesById',
                                                $category['Category']['id']
                                        ),
                                'update'   => 'submenu_' . 
$category['Category']['id'],
                                'complete' => 'showSubMenu(' . 
$category['Category']['id'] . ')'
                        );

                echo $ajax->link($category['Category']['name'],
                                                 
'/categories/getSubCategoriesById/' . $category['Category']
['id'],
                                                 $options);


                echo $ajax->div('submenu_' . $category['Category']['id'],
array('style' => 'display:none', 'class' => 'submenu'));

                if ($subcategories) {
                        foreach($subcategories as $subcategory) {
                                echo $subcategory['Category']['name'] . '<br 
/>';
                        }
                }
                echo $ajax->divEnd('submenu_' . $category['Category']['id']);

        ?>
        </li>
<?php endforeach; ?>
</ul>

How can I solve the problem?

Cheers
Sven

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to