Skip to content

Commit

Permalink
Fix issue if a listing page is fetched via setcontent
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohutai committed Aug 21, 2018
1 parent 5634c9d commit 96f1b68
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/HierarchicalRoutesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
class HierarchicalRoutesExtension extends SimpleExtension
{
/** @var string $permission The permission a user needs for interaction with the back-end */
/** @var string $permission The permission a user needs for interaction with the back-end */
private $permission = 'extensions';

/**
Expand Down
54 changes: 28 additions & 26 deletions templates/tree.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,37 @@
{% macro makeItem(item, children) %}

{% setcontent record = item %}
{% set editlink = record.editlink() %}

{% set title %}
<code>[{{ record.contenttype.slug }}/{{ record.id }}]</code>
<i class="fa fa-fw fa-circle status-{{ record.status }}"></i>
<a href="{{ record.link() }}">{{ record.title }}</a>
{# <a class="btn btn-tertiary btn-xs" href="{{ record.link() }}">View</a> #}
{% if record is not iterable %}
{% set editlink = record.editlink() %}
{% set title %}
<code>[{{ record.contenttype.slug }}/{{ record.id }}]</code>
<i class="fa fa-fw fa-circle status-{{ record.status }}"></i>
<a href="{{ record.link() }}">{{ record.title }}</a>
{# <a class="btn btn-tertiary btn-xs" href="{{ record.link() }}">View</a> #}

{% if editlink %}
<a class="btn btn-tertiary btn-xs" href="{{ editlink }}">Edit</a>
{% endif %}
{% endset %}
{% if editlink %}
<a class="btn btn-tertiary btn-xs" href="{{ editlink }}">Edit</a>
{% endif %}
{% endset %}

<li>
{% if children is not empty %}
<details open>
<summary>
{{ title }}
</summary>
<ol>
{% for i, j in children %}
{{ _self.makeItem(i, j) }}
{% endfor %}
</ol>
</details>
{% else %}
{{ title }}
{% endif %}
</li>
<li>
{% if children is not empty %}
<details open>
<summary>
{{ title }}
</summary>
<ol>
{% for i, j in children %}
{{ _self.makeItem(i, j) }}
{% endfor %}
</ol>
</details>
{% else %}
{{ title }}
{% endif %}
</li>
{% endif %}

{% endmacro %}

Expand Down

0 comments on commit 96f1b68

Please sign in to comment.