0251 / 590 837 15
info@a-coding-project.de
;

Menü Templates Teil 1 (CMS)

Im CMS ContentLion werden wir heute alles was im Admin-Bereich mit Menüs zu tun hat mit Templates ausstatten. Starten wir mit der Menüübersicht. Diese bekommt das Template /system/templates/menus.html:

<h1>{LANG:MENUS}</h1>
<p>
  <a href="{VAR:NEWMENUURL}">{LANG:NEW_MENU}</a>
</p>
<table>
  <thead>
    <tr>
      <td><strong>{LANG:ID}</strong></td>
      <td><strong>{LANG:NAME}</strong></td>
      <td><strong>{LANG:PAGES}</strong></td>
      <td><strong>{LANG:ACTIONS}</strong></td>
    </tr>
  </thead>
  <tbody>
    {LOOP:MENUS}
    <tr>
      <td>{VAR:ID}</td>
      <td>{VAR:NAME}</td>
      <td>{VAR:PAGES}</td>
      <td>
        <a title="Bearbeiten" href="{VAR:EDITURL}">
           <img src="{ICON:PAGE_EDIT}" />
        </a>
        <a title="L&ouml;schen" href="{VAR:DELETEURL}">
           <img src="{ICON:CROSS}" />
        </a>
      </td>
    </tr>
    {/LOOP:MENUS}
  </tbody>
</table>

Die dazugehörige Datei /admin/includes/menues.php sieht so aus:

<?PHP
  $template = new Template();
  $template->load("menus","../");
  $template->assign_var("NEWMENUURL","/admin/index.php?page=menue-new");
  foreach(sys::getMenues() as $menu){
    $index = $template->add_loop_item("MENUS");
    $template->assign_loop_var("MENUS", $index, "ID", $menu->id);
    $template->assign_loop_var("MENUS", $index, "NAME", $menu->name);
    $template->assign_loop_var("MENUS", $index, "PAGES", $menu->count);
    $template->assign_loop_var("MENUS", $index, "EDITURL", "index.php?page=menu-edit&menu=".$menu->id);
    $template->assign_loop_var("MENUS", $index, "DELETEURL", "index.php?page=menu-delete&menu=".$menu->id);
  }
  $template->output();
?>