Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow different field to be used as page label in list of pages #1122

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ warnings:
edit_mode: normal
frontend_pages_target: _blank
show_github_msg: true
pages_list_display_field: title
google_fonts: true
enable_auto_updates_check: true
notifications:
Expand Down
6 changes: 6 additions & 0 deletions blueprints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ form:
type: bool
help: Show the "Found an issue? Please report it on GitHub." message.

pages_list_display_field:
type: text
size: small
label: Pages List Display Field
help: "Field of the page to use in the list of pages if present. Defaults/Fallback to title."

enable_auto_updates_check:
type: toggle
label: Automatically check for updates
Expand Down
4 changes: 3 additions & 1 deletion themes/grav/templates/pages.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

{% macro loop(page, depth, twig_vars) %}
{% set separator = twig_vars['config'].system.param_sep %}
{% set display_field = twig_vars['config'].plugins.admin.pages_list_display_field %}
{% set base_url = twig_vars['base_url_relative'] %}
{% set base_url_simple = twig_vars['base_url_simple'] %}
{% set admin_route = twig_vars['admin_route'] %}
Expand Down Expand Up @@ -84,7 +85,8 @@
<div class="page-item__content">
<div class="page-item__content-name">
<span data-hint="{{ description|trim(' &bull; ')|raw }}" class="hint--top page-item__content-hint">
<a href="{{ page_url }}" class="page-edit">{{ p.title|e }}</a>
{% set page_label = attribute(p.header, display_field)|defined(attribute(p, display_field))|defined(p.title) %}
<a href="{{ page_url }}" class="page-edit">{{ page_label|e }}</a>
</span>
{% if p.language %}
<span class="badge lang {% if p.language == admin_lang %}info{% endif %}">{{p.language}}</span>
Expand Down