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

#22 : header_var with 'defined', not 'default' #25

Closed
wants to merge 3 commits into from
Closed

#22 : header_var with 'defined', not 'default' #25

wants to merge 3 commits into from

Conversation

hugobqd
Copy link

@hugobqd hugobqd commented May 11, 2018

The default state doesn't work with default when empty, use twig's defined instead

The default state doesn't work with default when empty, use twig's defined instead
@cweiske
Copy link

cweiske commented May 11, 2018

My issue was more that the "show_sidebar" setting is used to determine if the pagination should be shown.

@hugobqd
Copy link
Author

hugobqd commented May 11, 2018

OK, I see, I have modified the wrong variables assignments. Does the 'default' work fine for you?

@cweiske
Copy link

cweiske commented May 11, 2018

sorry, can't test right now.

@tribut
Copy link
Contributor

tribut commented May 27, 2018

Yes, both the logic (using show_sidebar for unrelated settings) and using default are broken. The changes in this PR make sense imho.

However, I suggest using the value from /blog for all the settings (and allow them to be overridden) like so:

{% set show_breadcrumbs = header_var('show_breadcrumbs')|defined(header_var('show_breadcrumbs', '/blog'))|defined(true) %}
{% set show_sidebar = header_var('show_sidebar')|defined(header_var('show_sidebar', '/blog'))|defined(true) %}
{% set show_pagination = header_var('show_pagination')|defined(header_var('show_pagination', '/blog'))|defined(true) %}

tribut added a commit to tribut/grav-theme-quark that referenced this pull request Jun 15, 2018
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
@tribut
Copy link
Contributor

tribut commented Jun 15, 2018

The settings where also inconsistently applied when comparing blog and item pages. I've fixed all of this in #37, which obsoletes this PR.

@hugobqd hugobqd closed this Jun 20, 2018
rhukster pushed a commit that referenced this pull request Jul 25, 2018
* Remove redundant default value for theme_var('blog-page')

The default value of `/blog` is already defined in the blueprint, so an
empty value will already always fall back correctly.

* Use correct function when looking for default value - #25

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 #25

* Use correct variable names when applying blog settings - #22

Fixes #22

* Use consistent lookup order for settings in blog page and items

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)
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.

3 participants