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

Add a way to disambiguate taxonomy tags from system tags in views #1195

Closed
steveparks opened this issue Jul 8, 2024 · 5 comments
Closed

Comments

@steveparks
Copy link

I created a taxonomy called 'Section', with the intention I could have paths like '/blog/section/{tag}'

Then, in my views I wanted to display the terms assigned to an entry on its view with {{ section }}

  • ...
  • {{ /section }}.

    This didn't work.

    In researching why, I found there is a Statamic system tag called {{ section }}, and this appears to create a conflict.

    So I guess that taxonomies can't be named the same thing as any of the existing Statmic tags.

    As section (and collection) are words that could often be used for taxonomies, it would be useful if there was a way of disambiguating between Statamic system tags and taxonomy tags in views.

    At the moment in a view, % can be used to signify a tag, and $ for a variable. But the % doesn't distinguish between types of tag.

    I suggest introducing an additional character, perhaps ^ to disambiguate Taxonomy tags in views. This will allow content designers and editors to name taxonomies anything they like, while enabling developers to build views that they know won't break.

    @jasonvarga
    Copy link
    Member

    But the % doesn't distinguish between types of tag.

    What do you mean "types" of tags?

    If you have a taxonomy named section, {{ section }} will still just be a variable. {{ $section }} should disambiguate it.

    @steveparks
    Copy link
    Author

    The $ can be used to disambiguate the variable, but what would you use to disambiguate the taxonomy?

    Eg how would you use this disambiguation to work with a taxonomy called 'section', such as:

    <ul>
    {{ section }}
     <li>{{ title}}
    {{ /section }}
    </ul>
    

    @jasonvarga
    Copy link
    Member

    <ul>
    {{ $section }}
     <li>{{ title}}
    {{ /$section }}
    </ul>
    

    @steveparks
    Copy link
    Author

    steveparks commented Aug 9, 2024

    ohhh I seeee - the taxonomy object is just another variable?

    I'd understood taxonomies were a special kind of tag. Ok, sorry, my bad.

    I'll close this, but I'll have a look if there's anything I can contribute to the docs page after learning from my confusion.

    Thanks for clarifying for me.

    @steveparks
    Copy link
    Author

    Ok, I submitted a PR to add a sentence in two places in the docs to explain this to newbs like me.
    #1434

    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

    No branches or pull requests

    2 participants