【问题标题】:wordpress style menu managerwordpress 风格的菜单管理器
【发布时间】:2012-12-19 23:42:55
【问题描述】:

我正在尝试使用php 和jquery-ui 为我自己的CMS 制作一个WordPress 风格的菜单管理器。我已经迈出了第一步,但我真的不知道我应该如何进行,尤其是如何实现菜单项之间的父子关系。我的实际代码看起来像

<style>
#sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
#sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; height: 1.5em; }
html>body #sortable li { height: 1.5em; line-height: 1.2em; }
.ui-state-highlight { height: 1.5em; line-height: 1.2em; }
</style>
<script>
$(function() {
    $( "#sortable" ).sortable({
        placeholder: "ui-state-highlight"
    });
    $( "#sortable" ).disableSelection();
});
</script>       
        <div class="admin_menus">
                            <ul id="sortable">
                            <?php foreach($menus as $menu): ?>
                                <?php if(array_key_exists('children', $menu)):?>         
                                <li class="ui-state-default">
                                 <?= $menu['name'] ?>
                                  <ul class="dropdown-menu_test">
                                    <?php foreach($menu['children'] as $menu_child):?>
                                    <li class="ui-state-default" ><?= $menu_child['name'] ?></li>
                                    <?php endforeach;?>

                                  </ul>

                                </li>
                                <?php else:?>
                                <li class="ui-state-default" ><?= $menu['name'] ?></li>
                                <?php endif;?>
                                <?php endforeach;?>                                                                         
                            </ul>
        </div>

$menus 存放着我从数据库中检索到的菜单项

【问题讨论】:

    标签: php jquery-ui menu drag-and-drop


    【解决方案1】:

    您可以使用此插件在您的网站中实现可拖动菜单功能 http://dbushell.github.io/Nestable/

    使用简单,可以自行定制。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-27
      相关资源
      最近更新 更多