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

Fix fallback values and load order for blog settings #37

Merged
merged 4 commits into from
Jul 25, 2018

Conversation

tribut
Copy link
Contributor

@tribut tribut commented Jun 15, 2018

This PR makes sure

  • the correct variable names are used for the blog settings (show_pagination = header_var(show_sidebar) #22)
  • the correct fallback-mechanism is used for the blog settings (#22 : header_var with 'defined', not 'default' #25)
  • Blog settings are always searched for in the following order:
    • Header variables in the current page
    • Settings from the page listed in the current page's header variable blog_url
    • Settings from the page listed in the theme variable blog-page (which defaults to /blog)
    • Default value (true)

Fixes #22
Obsoletes/Fixes #25

The default value of `/blog` is already defined in the blueprint, so an
empty value will already always fall back correctly.
Because twig's `default` filter checks for "undefined or empty" but
`header_var` returns `null` if it doesn't find anything, we have to use
Grav's `defined` filter (which checks `!== null`).

Fixes getgrav#25
The current behavior of sometimes using a default value from another
page is confusing. This commit ensures that the blog settings will
always use the first option found in the following list:

  1. Header variables from the current page
  2. Settings from the page in header variable `blog_url`
  3. Settings from the page in theme variable `blog-page`
  4. Default value (true)
@rhukster rhukster merged commit dd283fc into getgrav:develop Jul 25, 2018
@rhukster
Copy link
Member

Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants