title: Save full URL path in menu on Twig template engine
body: <blockquote>
    <p>/macros/subdepartments.html</p>
  </blockquote>
  
  <pre><code>{% macro displayChildren(departments, parent_id, deep, prefix) %}
      {% import _self as macros %}
      {% for dept in departments %}
          {% if dept.parent_id == parent_id %}
              {% set href = dept.seo_title ~ '/' ~ prefix %}
              &lt;li&gt;&lt;a href="/{{ href }}/{{ dept.id }}/dept" class="black" style="margin-left: {{ deep * 10 }}px;"&gt;{{ dept.title }}&lt;/a&gt;&lt;/li&gt;
              {{ macros.displayChildren(departments, dept.id, deep + 1, href) }}
          {% endif %}
      {% endfor %}
  {% endmacro %}
  </code></pre>
  
  <blockquote>
    <p>common.html</p>
  </blockquote>
  
  <pre><code>&lt;div class="departments"&gt;       
                  &lt;ul class="nav"&gt;
                      &lt;div class="clearfix"&gt;                              
                          {% import '/macros/subdepartments.html' as macros %}    
                          {% for dept in common.departments %}
                              {% if dept.parent_id == 0 %}
                                  &lt;li&gt;&lt;a href="/{{ dept.seo_title }}/{{ dept.id }}/dept" class="black"&gt;{{ dept.title }}&lt;/a&gt;&lt;div class="dropdown-menu"&gt;&lt;ol class="nav"&gt;{{ macros.displayChildren(common.departments, dept.id, 0, dept.seo_title) }}&lt;/ol&gt;&lt;/div&gt;&lt;/li&gt;
                              {% endif %}
                          {% endfor %}
                      &lt;/div&gt;                  
                  &lt;/ul&gt;
              &lt;/div&gt;
  </code></pre>
  
  <blockquote>
    <p>department.html (extended from common.html by Twig)</p>
  </blockquote>
  
  <pre><code>&lt;ol class="nav" style="margin-left: 10px;"&gt;
          {% for dept in common.departments %}
              {% if dept.id == selected_dept.parent_id %}
                  &lt;li&gt;&lt;a href="/{{ dept.seo_title }}/{{ dept.id }}/dept" class="black"&gt;← {{ dept.title }}&lt;/a&gt;&lt;/li&gt;
              {% endif %}
              {% if dept.parent_id != 0 or dept.id == selected_dept.id %}
                  {% if dept.parent_id == selected_dept.parent_id %}
                      &lt;li&gt;&lt;a href="/{{ dept.seo_title }}/{{ dept.id }}/dept" class="black{% if dept.id == selected_dept.id %} selected{% endif %}"&gt;{{ dept.title }}&lt;/a&gt;&lt;/li&gt;
                      {{ macros.displayChildren(common.departments, dept.id, 1) }}    
                  {% endif %}
              {% endif %}
          {% endfor %}&lt;/ol&gt;
  </code></pre>
  
  <blockquote>
    <p>common.departments array</p>
  </blockquote>
  
  <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 1 [parent_id] =&gt; 0 [title] =&gt; Моторные масла [seo_title] =&gt; motor-oils [full_title] =&gt; [display] =&gt; 1 ) [1] =&gt; Array ( [id] =&gt; 2 [parent_id] =&gt; 0 [title] =&gt; Трансмиссионные масла [seo_title] =&gt; transmission-oils [full_title] =&gt; [display] =&gt; 1 ) [2] =&gt; Array ( [id] =&gt; 3 [parent_id] =&gt; 0 [title] =&gt; Присадки [seo_title] =&gt; additives [full_title] =&gt; [display] =&gt; 1 ) [3] =&gt; Array ( [id] =&gt; 4 [parent_id] =&gt; 0 [title] =&gt; Автокосметика [seo_title] =&gt; autocosmetics [full_title] =&gt; [display] =&gt; 1 ) [4] =&gt; Array ( [id] =&gt; 5 [parent_id] =&gt; 0 [title] =&gt; Сервисные продукты [seo_title] =&gt; service-products [full_title] =&gt; [display] =&gt; 1 ) [5] =&gt; Array ( [id] =&gt; 6 [parent_id] =&gt; 0 [title] =&gt; Технологические жидкости [seo_title] =&gt; process-fluids [full_title] =&gt; [display] =&gt; 1 ) [6] =&gt; Array ( [id] =&gt; 7 [parent_id] =&gt; 0 [title] =&gt; Зимняя программа [seo_title] =&gt; winter-program [full_title] =&gt; [display] =&gt; 1 ) [7] =&gt; Array ( [id] =&gt; 8 [parent_id] =&gt; 1 [title] =&gt; Синтетические [seo_title] =&gt; synthetic [full_title] =&gt; Синтетические моторные масла [display] =&gt; 1 ) [8] =&gt; Array ( [id] =&gt; 9 [parent_id] =&gt; 1 [title] =&gt; Полусинтетические [seo_title] =&gt; semisynthetic [full_title] =&gt; Полусинтетические моторные масла [display] =&gt; 1 ) [9] =&gt; Array ( [id] =&gt; 10 [parent_id] =&gt; 1 [title] =&gt; Минеральные [seo_title] =&gt; mineral [full_title] =&gt; Минеральные моторные масла [display] =&gt; 1 ) [10] =&gt; Array ( [id] =&gt; 11 [parent_id] =&gt; 2 [title] =&gt; для МКПП (механика) [seo_title] =&gt; mt [full_title] =&gt; Трансмиссионные масла для МКПП [display] =&gt; 1 ) [11] =&gt; Array ( [id] =&gt; 12 [parent_id] =&gt; 2 [title] =&gt; для АКПП (автомат) [seo_title] =&gt; at [full_title] =&gt; Трансмиссионные масла для АКПП [display] =&gt; 1 ) [12] =&gt; Array ( [id] =&gt; 13 [parent_id] =&gt; 12 [title] =&gt; Test [seo_title] =&gt; test [full_title] =&gt; Test [display] =&gt; 1 ) ) 
  </code></pre>
  
  <p>In common.html all ok. In deparment.html I need to get the same href in {{ dept.seo_title }}. If I go to /at/transmission-oils/13/dept from common.html in the department.html I see wrong urls to the departments.</p>
  
  <pre><code>← Трансмиссионные масла (href: /transmission-oils/2/dept right!)
  для МКПП (механика) (href: mt/11/dept wrong!, need to be /mt/transmission-oils/11/dept)
  для АКПП (автомат) (href: at/12/dept wrong!, need to be /at/transmission-oils/12/dept)
  Test (href: /test//13/dept wrong!, need to be /test/at/transmission-oils/13/dept)
  </code></pre>
  
  <p>So, how can I change the code in department.html to print full path to subdepartment? Maybe recursive function will get the all parent departments. </p>