{math equation="x/8" x=$node.vector_depth assign="crd"} {*// hlbka vektora - pocet nod vo vektore *}


{if $template_event eq 'filter_by'} {get_threaded_children listing_amount=23232322323 offset=$offset search_type=$post_vars.search_type link='yes'  ordearby=$listing_order search=$post_vars.node_content}
{else}
{get_threaded_children link='yes' listing_amount=100 offset=0 ordearby=$listing_order}
{/if}
<CHILDREN k_num='{$user_k}' w_num='{$k_wallet}'>
{section name=child loop=$get_threaded_children}{if $get_threaded_children[child].template_id neq 1549834}
{*position in tree*}
{math equation="(x/8)-y" x=$get_threaded_children[child].depth y=$crd assign="hierarch"}
{math equation="(x/8)-y" x=$get_threaded_children[child.index_prev].depth y=$crd assign="prev_depth"}
{math equation="(x/8)-y" x=$get_threaded_children[child.index_next].depth y=$crd assign="next_depth"}
{*depth in hierarchy*}
{if $smarty.section.child.last}{math equation="x-1" x=$hierarch assign="h_depth"}{else}{math equation="x-y" x=$hierarch y=$next_depth assign="h_depth"}{/if}
{*root_id decka*}
{str_split string=$get_threaded_children[child].node_vector name=hroot length=8}
{eval var=$str_split.hroot.$crd assign="h_root"}
{str_split string=$get_threaded_children[child.index_prev].node_vector name=proot length=8}
{eval var=$str_split.proot.$crd assign="p_root"}
{str_split string=$get_threaded_children[child.index_next].node_vector name=nroot length=8}
{eval var=$str_split.nroot.$crd assign="n_root"}
{*depth in hierarchy*}{if $template_event eq 'filter_by'}{math equation="(x-y)" x=$hierarch y=$prev_depth assign="p_depth"}{else}{math equation="(x-y)-1" x=$hierarch y=$prev_depth assign="p_depth"}{/if}{*(x-y)-1*}
{math equation="x-1" x=$hierarch assign="ph_depth"}
{math equation="x-y" x=$next_depth y=$hierarch assign="c_depth"}
{if $smarty.section.child.last}
{math equation="x-1" x=$hierarch assign="h_depth"}
{elseif $h_root neq $n_root && $get_threaded_children[child].node_status neq 'linked'}
{math equation="x-1" x=$hierarch assign="h_depth"}
{elseif $h_root neq $n_root && $get_threaded_children[child.index_next].node_status neq 'linked'}
{math equation="x-1" x=$hierarch assign="h_depth"}
{else}
{math equation="x-y" x=$hierarch y=$next_depth assign="h_depth"}
{/if}
{math equation="x+1" x=$crd assign="starter"}

{*obsah childu*}
{capture name=child_container}
<TITLE><![CDATA[{$get_threaded_children[child].node_name}]]></TITLE>
<CONTENT><![CDATA[{$get_threaded_children[child].node_content}]]></CONTENT>
{/capture} 

{*stromcek prestri sa*}
{if $smarty.section.child.first && $sterter < $hierarch}
{section name=sta loop=$ph_depth}
<CHILD PRESENCE='virtual'>
{/section}
{/if}
{if $get_threaded_children[child].node_parent neq $node.node_id && $get_threaded_children[child].node_status neq 'linked' && $get_threaded_children[child].node_parent neq $get_threaded_children[child.index_prev].node_id && $prev_depth < $hierarch} 
{section name=sta loop=$p_depth}
<CHILD PRESENCE='virtual'>
{/section}
{elseif $get_threaded_children[child].node_parent neq $node.node_id && $get_threaded_children[child.index_prev].node_status neq 'linked' && $get_threaded_children[child].node_parent neq $get_threaded_children[child.index_prev].node_id && $prev_depth < $hierarch} 
{section name=sta loop=$p_depth}
<CHILD PRESENCE='virtual'>
{/section}
{elseif $h_root neq $p_root && $get_threaded_children[child].node_parent neq $node.node_id && $get_threaded_children[child].node_status neq 'linked'}
{section name=sta loop=$ph_depth}
<CHILD PRESENCE='virtual'>
{/section}
{elseif $h_root neq $p_root && $get_threaded_children[child].node_parent neq $node.node_id && $get_threaded_children[child.index_prev].node_status neq 'linked'} 
{section name=sta loop=$hp_depth}
<CHILD PRESENCE='virtual'>
{/section}
{/if}
  <CHILD id='sub{$get_threaded_children[child].node_id}' creatorid='{$get_threaded_children[child].node_creator}' creatornick='{$get_threaded_children[child].login}' vector='{$get_threaded_children[child].node_vector}' created='{$get_threaded_children[child].node_created|date_format:"%d.%m.%Y - %H:%M:%S"}}'{if $get_threaded_children[child].node_updated} updated='{$get_threaded_children[child].node_updated|date_format:"%d.%m.%Y - %H:%M:%S"}'{/if}{if $get_threaded_children[child].k > 0} k='{$get_threaded_children[child].k}'{/if} h='{$hierarch}'{if $get_threaded_children[child.index_next].node_status eq 'linked'} linked='true'{/if}>
      {$smarty.capture.child_container} {*obsah*}
{if $next_depth > $hierarch && $h_root neq $p_root && $get_threaded_children[child].node_parent neq $node.node_id}
{section name=con loop=$c_depth}
  <CHILD PRESENCE='virtual'>
{/section}

{elseif $next_depth > $hierarch && $h_root eq $n_root && $get_threaded_children[child.index_next].node_status neq 'linked'}
    {elseif $next_depth > $hierarch && $get_threaded_children[child.index_next].node_status eq 'linked'}{else}
  </CHILD>
{/if}{if $next_depth < $hierarch || $h_root neq $n_root || $smarty.section.child.last}
{section name=fin loop=$h_depth}
  </CHILD>
{/section}{/if}
{/if}{/section}
</CHILDREN>