Header/Footer items config: Add configurable permissions
This commit is contained in:
parent
4fa99b8a04
commit
4244acfb4d
|
@ -32,14 +32,22 @@ return [
|
|||
// Available link placeholders: %lang%
|
||||
// To disable a header_item in the config.php, you can set its value to null
|
||||
'header_items' => [
|
||||
//'Foo' => 'https://foo.bar/batz-%lang%.html',
|
||||
// 'Name' => 'URL',
|
||||
// 'Name' => ['URL', 'permission'],
|
||||
// Name can be a translation string, permission is a engelsystem privilege
|
||||
|
||||
//'Foo' => ['https://foo.bar/batz-%lang%.html', 'logout'], // Permission: for logged-in users
|
||||
],
|
||||
|
||||
// Footer links
|
||||
// To disable a footer item in the config.php, you can set its value to null
|
||||
'footer_items' => [
|
||||
// 'Name' => 'URL',
|
||||
// 'Name' => ['URL', 'permission'],
|
||||
// Name can be a translation string, permission is a engelsystem privilege
|
||||
|
||||
// URL to the angel faq and job description
|
||||
'FAQ' => env('FAQ_URL', '/faq'),
|
||||
'faq.faq' => [env('FAQ_URL', '/faq'), 'faq.view'],
|
||||
|
||||
// Contact email address, linked on every page
|
||||
'Contact' => env('CONTACT_EMAIL', 'mailto:ticket@c3heaven.de'),
|
||||
|
|
|
@ -36,11 +36,15 @@
|
|||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% for name,url in config('footer_items') %}
|
||||
{% for name,opt in config('footer_items') %}
|
||||
{% set url = opt is iterable ? opt[0] : opt %}
|
||||
{% set permission = opt is iterable ? opt[1] : null %}
|
||||
{% if not permission or has_permission_to(permission) %}
|
||||
<a href="{% if url starts with '/' %}{{ url(url) }}{% else %}{{ url }}{% endif %}">
|
||||
{% if '@' in url %}{{ m.icon('envelope') }}{% endif %}
|
||||
{{ __(name) }}
|
||||
</a> ·
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<a href="https://github.com/engelsystem/engelsystem/issues">{{ __('footer.issues') }}</a>
|
||||
· <a href="https://github.com/engelsystem/engelsystem/">{{ __('footer.github') }}</a>
|
||||
|
|
|
@ -45,12 +45,18 @@
|
|||
|
||||
{% if config('header_items') %}
|
||||
<ul class="navbar-nav mb-2 mb-lg-0">
|
||||
{% for text,link in config('header_items', {}) %}
|
||||
{% for name,opt in config('header_items', {}) %}
|
||||
{% set url = opt is iterable ? opt[0] : opt %}
|
||||
{% set permission = opt is iterable ? opt[1] : null %}
|
||||
{% if not permission or has_permission_to(permission) %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ link|replace({'%lang%': session_get('locale')|split('_')[0]})|escape('html_attr') }}">
|
||||
{{ text }}
|
||||
<a class="nav-link"
|
||||
href="{{ url|replace({'%lang%': session_get('locale')|split('_')[0]})|escape('html_attr') }}"
|
||||
>
|
||||
{{ __(name) }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue