1
我正在尝试使用php
和jquery-ui
为我自己的CMS创建一个WordPress样式菜单管理器。我已经做出了第一步,但我不知道该如何继续,特别是如何实现菜单项之间的父子关系。我实际的代码看起来像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
拥有数据库