source: trunk/admin/themes/default/template/cat_list.tpl @ 6698

Revision 6698, 5.1 KB checked in by plg, 10 years ago (diff)

feature 408: ability to automatically sort sub-categories. The number of SQL
queries is constant, no matter the deepth of your tree.

+ refactor to avoid duplicate code (ascending/desceding should be only a
single parameter in a function, not 20 lines of duplicated code)

  • Property svn:eol-style set to LF
Line 
1{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
2{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js" }
3{known_script id="jquery.ui.sortable" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.sortable.packed.js" }
4
5<script type="text/javascript">
6  jQuery().ready(function(){ldelim}
7    jQuery(".catPos").hide();
8    jQuery(".drag_button").show();
9    jQuery(".categoryLi").css("cursor","move");
10    jQuery(".categoryUl").sortable({ldelim}
11      axis: "y",
12      opacity: 0.8
13    });
14    jQuery("#categoryOrdering").submit(function(){ldelim}
15      ar = jQuery('.categoryUl').sortable('toArray');
16      for(i=0;i<ar.length;i++) {ldelim}
17        cat = ar[i].split('cat_');
18        document.getElementsByName('catOrd[' + cat[1] + ']')[0].value = i;
19      }
20    });
21
22    jQuery("input[name=order_type]").click(function () {ldelim}
23      jQuery("#automatic_order_params").hide();
24      if (jQuery("input[name=order_type]:checked").val() == "automatic") {ldelim}
25        jQuery("#automatic_order_params").show();
26      }
27    });
28  });
29</script>
30
31<h2>{'Categories management'|@translate}</h2>
32
33<h3>{$CATEGORIES_NAV}</h3>
34
35<form id="addVirtual" action="{$F_ACTION}" method="post">
36  <p>
37    <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
38    {'Add a virtual category'|@translate} : <input type="text" name="virtual_name">
39    <input class="submit" type="submit" value="{'Submit'|@translate}" name="submitAdd" {$TAG_INPUT_ENABLED}>
40    {if count($categories)>9 }
41    <a href="#EoP" class="button" style="border:0;">
42                <img src="{$themeconf.admin_icon_dir}/page_end.png" title="{'Page end'|@translate}" class="button" alt="page_end" style="margin-bottom:-0.6em;"></a>
43    {/if}
44  </p>
45</form>
46
47{if count($categories) }
48<form id="categoryOrdering" action="{$F_ACTION}" method="post">
49  <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
50
51  <div class="orderParams">
52    <input class="submit" name="submitOrder" type="submit" value="{'Save order'|@translate}" {$TAG_INPUT_ENABLED}>
53    <label><input type="radio" name="order_type" value="manual" checked="checked"> {'manual order'|@translate}</label>
54    <label><input type="radio" name="order_type" value="automatic"> {'automatic order'|@translate}</label>
55    <span id="automatic_order_params" style="display:none">
56      <select name="ascdesc">
57        <option value="asc">{'ascending'|@translate}</option>
58        <option value="desc">{'descending'|@translate}</option>
59      </select>
60      <label><input type="checkbox" name="recursive"> {'apply to sub-categories'|@translate}</label>
61    </span>
62  </div>
63
64  <ul class="categoryUl">
65
66    {foreach from=$categories item=category}
67    <li class="categoryLi{if $category.IS_VIRTUAL} virtual_cat{/if}" id="cat_{$category.ID}">
68      <!-- category {$category.ID} -->
69      <ul class="categoryActions">
70        {if cat_admin_access($category.ID)}
71        <li><a href="{$category.U_JUMPTO}" title="{'jump to category'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_jump-to.png" class="button" alt="{'jump to category'|@translate}"></a></li>
72        {/if}
73        <li><a href="{$category.U_EDIT}" title="{'edit category informations'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'edit'|@translate}"></a></li>
74        {if isset($category.U_MANAGE_ELEMENTS) }
75        <li><a href="{$category.U_MANAGE_ELEMENTS}" title="{'manage category elements'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_elements.png" class="button" alt="{'elements'|@translate}"></a></li>
76        {/if}
77        <li><a href="{$category.U_CHILDREN}" title="{'manage sub-categories'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_children.png" class="button" alt="{'sub-categories'|@translate}"></a></li>
78        {if isset($category.U_MANAGE_PERMISSIONS) }
79        <li><a href="{$category.U_MANAGE_PERMISSIONS}" title="{'edit category permissions'|@translate}" ><img src="{$themeconf.admin_icon_dir}/category_permissions.png" class="button" alt="{'Permissions'|@translate}"></a></li>
80        {/if}
81        {if isset($category.U_DELETE) }
82        <li><a href="{$category.U_DELETE}" title="{'delete category'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/category_delete.png" class="button" alt="{'delete'|@translate}"></a></li>
83        {/if}
84      </ul>
85
86      <p>
87      <img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" style="display:none;" alt="{'Drag to re-order'|@translate}" title="{'Drag to re-order'|@translate}">
88      <strong><a href="{$category.U_CHILDREN}" title="{'manage sub-categories'|@translate}">{$category.NAME}</a></strong>
89      {if $category.IS_VIRTUAL}
90      <img src="{$themeconf.admin_icon_dir}/virt_category.png" class="button" alt="{'Virtual category'|@translate}">
91      {/if}
92      </p>
93
94      <p class="catPos">
95        <label>
96          {'Position'|@translate} :
97          <input type="text" size="4" name="catOrd[{$category.ID}]" maxlength="4" value="{$category.RANK}">
98        </label>
99      </p>
100
101    </li>
102    {/foreach}
103  </ul>
104</form>
105{/if}
Note: See TracBrowser for help on using the repository browser.