{% load phoxtail_design_tags phoxtail_agent_tags %} {% url 'wagtailadmin_home' as admin_home %} {% for p in pages %} {# on_trail: this node is the active page itself, or one of its ancestors — auto-expanded instead of lazy #} {% with on_trail=p.pk|in_set:active_ancestor_ids %}
{% if not flat and p.numchild %} {% if on_trail %} {% else %} {# Fetch driven from media_picker.js, not hx-trigger="click once", so failures stay retryable #} {% endif %} {% else %} {% endif %} {% icon p.numchild|yesno:"folder,doc_full_inverse" class="phoxtail-media-picker-menu-row-icon" %} {# draggable="false" kills the native link drag so the row's page payload wins #} {{ p.title|truncatechars:32 }} {% if flat %} {{ p.url_path|slice:"1:-1" }} {% endif %}
{% if not flat and p.numchild %} {% if on_trail %} {% page_children p active_ancestor_ids as trail %}
{% include "phoxtail_agent/partials/menu_picker_nodes.html" with pages=trail.pages flat=False active_page_id=active_page_id active_ancestor_ids=active_ancestor_ids %} {% if trail.has_more %} {% endif %}
{% else %} {% endif %} {% endif %}
{% endwith %} {% empty %} {% if flat %}
No pages match
{% endif %} {% endfor %}