树类结构?

时间:2013-07-11 07:47:41

标签: php javascript jquery ajax marketplace

我想在卖家页面中显示树状结构中的类别这是我在Magento CE1.7中的市场扩展我正在进入下拉列表但它看起来不太好。

任何想法

<?php $_helper = Mage::helper('catalog/category') ?>
                <?php $_categories = $_helper->getStoreCategories() ?>
                <?php $currentCategory = Mage::registry('current_category') ?>
                <?php if (count($_categories) > 0): ?>
                    <select id="category" class="myinput-text required-entry widthinput" name="category">
                    <option value="">--Select Categories--</option>
                    <?php $_helper = Mage::helper('catalog/category') ?>
                    <?php $_categories = $_helper->getStoreCategories() ?>
                    <element onclick="<?php $currentCategory = Mage::registry('current_category') ?>">
                <?php if (count($_categories) > 0): ?>
                        <?php foreach($_categories as $_category): ?>
                            <option value="<?php echo $_category->getId() ?>">
                                <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                                        <?php echo $_category->getName() ?></a>
                        </option>
                                <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                                <?php $_subcategories = $_category->getChildrenCategories() ?>
                        <?php if (count($_subcategories) > 0): ?>
                                <?php foreach($_subcategories as $_subcategory): ?>
                                        <option value="<?php echo $_subcategory->getId() ?>">
                                        <?php echo '&nbsp;&nbsp;&nbsp;<img/>'; ?>
                                            <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
                        <?php echo $_subcategory->getName() ?></a>
                            </option>
                                <?php $_subcategory = Mage::getModel('catalog/category/subcategory')->load($_subcategory->getId()) ?>
                                <?php $_subsubcategories = $_subcategory->getChildrenCategories() ?>
                        <?php if (count($_subsubcategories) > 0): ?>
                                <?php foreach($_subsubcategories as $_subsubcategory): ?>
                                        <option value="<?php echo $_subsubcategory->getId() ?>">
                                        <?php echo '&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;       '; ?>
                                        <a href="<?php echo $_helper->getCategoryUrl($_subsubcategory) ?>">
                        <?php echo $_subsubcategory->getName() ?></a>
                        </option>
                    <?php endforeach; ?>
                <?php endif; ?>
                            <?php endforeach; ?>
                        <?php endif; ?>
                        <?php endforeach; ?>
                <?php endif; ?></select>
                <?php endif; ?>
抱歉,每一个这都不是重复的代码,在这个地方只有我必须改变,因为剩下的每一件事都是完美的500行代码

谢谢

0 个答案:

没有答案