-
-
Notifications
You must be signed in to change notification settings - Fork 811
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
[RFC] Twig relationship/taxonomy functions & filters #6774
[RFC] Twig relationship/taxonomy functions & filters #6774
Conversation
Updated the RFC examples with some comments, and a first "simpler" example for each … and a left out parameter that some 🐨 forgot to cherry-pick from the "messing around branch" |
OK, seeing as this is PoC & RFC, I've also added the other thing that doesn't belong, as an object, coupled to the entity … Internally, it just returns a recursive {{ contenttype }} {# Get the ContentType definition for this record #}
{% set contenttype = contenttype(record) %} Example use: {% set contenttype = contenttype(record) %}
{# A nice title with the configured icon (colon thing wasn't my idea) #}
<h4><i class="fa {{ contenttype.icon_many|replace(':', '-') }}"></i>
{{ contenttype.name }} ContentType</h4>
{# Accessing the a field configuration parameter for the field named 'image' #}
{% set extensions = contenttype.getPath('fields/image/extensions') %}
<p>The 'image' field accepts these file extensions: {{ extensions|join(', ') }}</p>
{# What taxonomies are defined as available for the ContentType of *this* record #}
<p>Available taxonomies: {{ contenttype.taxonomy|join(', ') }}</p>
{# What ContentTypes are defined as available to be related to this *this* record #}
{# Note that 'contenttype.relations' contains the parameters relevant,
# so using 'keys' just returns their names #}
<p>Relatable ContentTypes: {{ contenttype.relations.keys|join(', ') }}</p> |
We didn't get around to discussing this yet during the dev-meeting, so let's let it sit for a bit. |
Yeah, zero stress … That's the idea of this one … it can hang around for a while as it is not a lot of work to maintain (unlike other branches), plus I am not convinced this is exactly what we want (I think it is close-ish though) … Oh, and WRT to the debugging stuff, that is not the scope for this one specifically (probably at all), as that will require a bit more work and help from Team Texas when he's back online. Nonetheless what we agree on here affects how that will be handled to an extent. |
OK, so I had some time to waste waiting on PRs to get merged, and I got thinking about the debate at the last meeting regarding decoupling relationships & taxonomy objects from an entity in v4.
The point of contention was how we would approach that, so this is a PoC RFC … that I am either happy to see though to merge if we all like the approach, or just close the RFC and delete the branch if we think not … really, it wasn't a lot of work and I was bored! 🤣
Have a look, talk to me!
EDIT: It is worth noting that these are registered as filters & functions, the examples below are done using the Twig functions, 'cause personal taste.
{{ related }}
Example use:
{{ taxonomy }}
Example use: