mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-07-14 22:02:09 +02:00
Fixed tab highlighting
This commit is contained in:
@@ -1,28 +1,30 @@
|
||||
<div class="form-tabs {{ field.class }}">
|
||||
|
||||
{% if uri.params.tab %}
|
||||
{% set active = uri.params.tab %}
|
||||
{% elseif field.active %}
|
||||
{% set active = field.active %}
|
||||
{% else %}
|
||||
{% set active = 1 %}
|
||||
{% endif %}
|
||||
|
||||
{{ dump(active) }}
|
||||
|
||||
|
||||
|
||||
|
||||
{% if field.fields %}
|
||||
{% set storedValue = get_cookie('grav-tabs-state')|default('{}')|json_decode %}
|
||||
|
||||
{% set tabsKey = field.fields|keys|join('.') %}
|
||||
{% set storedValue = get_cookie('grav-tabs-state')|default('{}')|json_decode %}
|
||||
{% set storedTab = attribute(storedValue, 'tab-' ~ tabsKey) %}
|
||||
|
||||
{% if storedTab is empty %}
|
||||
{% if uri.params.tab %}
|
||||
{% set active = uri.params.tab %}
|
||||
{% elseif field.active %}
|
||||
{% set active = field.active %}
|
||||
{% else %}
|
||||
{% set active = 1 %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<div class="tabs-nav">
|
||||
{% for tab in field.fields %}
|
||||
{% if tab.type == 'tab' and (tab.security is empty or authorize(array(tab.security))) %}
|
||||
{#<input type="radio" name="tab-{{ tabsKey }}" id="tab-{{ tabsKey ~ loop.index }}" value="{{ (scope ~ tab.name) }}" class="tab-head no-form" />#}
|
||||
{#<label for="tab-{{ tabsKey ~ loop.index }}">#}
|
||||
{#{% if grav.twig.twig.filters['tu'] is defined %}{{ tab.title|tu }}{% else %}{{ tab.title|t }}{% endif %}#}
|
||||
{#</label>#}
|
||||
|
||||
<a class="tab__link {{ ((attribute(storedValue, 'tab-' ~ tabsKey) == scope ~ tab.name) or active == loop.index) ? 'active' : '' }}" href="#" data-tabid="tab-{{ tabsKey ~ loop.index }}">
|
||||
<a class="tab__link {{ (storedTab == scope ~ tab.name) or active == loop.index ? 'active' : '' }}" href="#" data-tabid="tab-{{ tabsKey ~ loop.index }}">
|
||||
{% if grav.twig.twig.filters['tu'] is defined %}{{ tab.title|tu }}{% else %}{{ tab.title|t }}{% endif %}
|
||||
</a>
|
||||
{% endif %}
|
||||
@@ -33,7 +35,7 @@
|
||||
{% if field.type == 'tab' %}
|
||||
{% if field.security is empty or authorize(array(field.security)) %}
|
||||
{% set value = data.value(field.name) %}
|
||||
<div id="tab-content-{{ tabsKey ~ loop.index }}" class="tab__content {{ ((attribute(storedValue, 'tab-' ~ tabsKey) == scope ~ tab.name) or active == loop.index) ? 'active' : '' }}">
|
||||
<div id="tab-content-{{ tabsKey ~ loop.index }}" class="tab__content {{ (storedTab == scope ~ field.name) or active == loop.index ? 'active' : '' }}">
|
||||
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user