{function printTree}
   {foreach $data as $entry}
      {if !$zero && $entry.id === 0}
         {continue}
      {/if}
      {$width = 500 - ($entry.level * 26)}
      <li class="node {$view->resolveCallable($tableDef.class, $entry)}"
          data-id="{$view->getListRowValue($entry, $tableDef.id)}">
         <div class="nodeWrapper tdd-row">
            {foreach $tableDef.fields as $name => $column}
               {if ($column.wpjAdmin and !isSuperuser()) or $column.visible == 'N'}
                  {continue}
               {/if}
               <div class="list_item {if $isEditing}is-editable{/if} tdd-column tdd-column-{$column@index + 1} {$view->resolveCallable($column.class, $entry) nofilter}">
                  {$view->printListRowItem($column, $entry)}
               </div>
            {/foreach}
         </div>
         {if !empty($entry.children) && ($openedSections == 'all' || in_array($entry.id, $openedSections))}
            <ul class="tdd-tree">
               {printTree data=$entry.children tableDef=$tableDef}
            </ul>
         {/if}
      </li>
   {/foreach}
{/function}

{if $SQL[0].id === 0}
   <div class="table">
      <ul class="sections-root">
         {printTree data=[$SQL[0]] tableDef=$columns zero=true}
      </ul>
   </div>
{/if}

<div class="treeDragDrop sections-sortable table" id="sectionsRoot">
   <ul class="tdd-tree nestedSortable nestedSortableRoot">
       {printTree data=$SQL tableDef=$columns}
   </ul>
</div>
