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

[UX] Blocks: Add a "Taxonomy term: Depth" Visibility condition #2955

Open
jenlampton opened this Issue Jan 25, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@jenlampton
Copy link
Member

jenlampton commented Jan 25, 2018

Describe your issue or idea

Just as I often have different layouts for nodes, by node-type, I often need different layouts for categories based on term-depth. For example, my top-level terms need landing pages, but my deeper terms could use their own layout (or even the default layout).

However, without a Visibility condition to select only the top-level terms, I'm at a bit of a loss.


PR: backdrop/backdrop#2081

@docwilmot

This comment has been minimized.

Copy link
Contributor

docwilmot commented Apr 26, 2018

Tested this in the sandbox:

  • added a layout for taxonomy/term/%
  • went to add block: the new "Term depth" condition was available
  • added block with condition depth 1
  • added some hierarchical terms and visited their pages
  • block is only visible on term pages of top terms as expected.

I wonder if a description of "Depth" on the form() method might be good since term depth isn't likely to be a well-understood concept.

And maybe tests but we seem to have no tests for other access plugins so no fault there.

I think we could use taxonomy_term_load_parents_all() instead of the current query. With a depth of 4, you would be making 4 queries as it is now, whereas taxonomy_term_load_parents_all() uses a static cache. I havent checked but I wonder if a simple count() on the results of that function would give the depth.

@jenlampton

This comment has been minimized.

Copy link
Member

jenlampton commented Apr 28, 2018

I wonder if a description of "Depth" on the form() method might be good since term depth isn't likely to be a well-understood concept.

That's a good idea. I tried to re-use terminology found in Views so that we'd at least be consistent, but yes more explanation might be necessary.

With a depth of 4, you would be making 4 queries as it is now

I looked for other core API functions that we could use for this, but didn't find anything suitable.

I wonder if a simple count() on the results of taxonomy_term_load_parents_all() would give the depth.

It might, in some cases (though perhaps not all as a term can have multiple parents). The function taxonomy_term_load_parents_all() also unnecessarily loads all the parent terms, which would generate dozens of extra queries when the value isn't in the static cache, and that would make this code much slower. We could add our own static cache here if that would make a significant difference.

@jenlampton jenlampton modified the milestones: 1.10.0, 1.11.0 May 2, 2018

@jenlampton

This comment has been minimized.

Copy link
Member

jenlampton commented May 2, 2018

Changing to NW and bumping milestone.

@klonos

This comment has been minimized.

Copy link
Member

klonos commented Jul 18, 2018

Thanks for opening this ticket @jenlampton ...and for the PR 👍

It's those little things that make backdrop great 😄

PS: I wonder if the same concept could be implemented for URL path depth. If the wildcard * works when used multiple times (never actually tried it), then this is moot. For example landing pages could have a visibility condition of /something/*, and sub pages would have their visibility condition set to /something/*/*. Anyone tried this before?

@quicksketch quicksketch modified the milestones: 1.11.0, 1.12.0 Sep 6, 2018

@jenlampton

This comment has been minimized.

Copy link
Member

jenlampton commented Dec 13, 2018

I found that no level of explanation was as good as a visual example, so I kept it short and added a visual example :)

screen shot 2018-12-12 at 8 40 36 pm

@klonos klonos changed the title [UX] Add a "Term Depth" Visibility condition for the taxonomy context [UX] Blocks: Add a "Taxonomy term: Depth" Visibility condition Dec 13, 2018

@jenlampton jenlampton modified the milestones: 1.12.0, 1.13.0 Jan 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment