Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
id in category list
It would be nice if category_list also offered an id attribute. For example, instead of
<ul id="menu">
<txp:category_list break="li" wraptag="" />
</ul>
we could have
<txp:category_list break="li" wraptag="ul" id="menu" />
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: id in category list
That might confuse people with Textpattern’s internal IDs though.
Offline
Re: id in category list
what if we call it wrapid?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#4 2015-04-14 07:57:33
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: id in category list
Offline
Re: id in category list
That would work, please raise a GitHub issue for this.
Offline
Re: id in category list
On the surface it’s a 2-line patch, and makes sense. But what would you have the attribute do if wraptag was omitted? Ignore it?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: id in category list
Bloke wrote #289975:
On the surface it’s a 2-line patch, and makes sense. But what would you have the attribute do if
wraptagwas omitted? Ignore it?
For backward compatibility, yes, I would ignore it. Also should this be implemented for the section_list tag too?
philwareham wrote #289974:
That would work, please raise a GitHub issue for this.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: id in category list
colak wrote #289979:
Also should this be implemented for the
section_listtag too?
as well as for each of ~30 tags having wraptag? I would go the opposite way: reduce the number of built-in HTML attributes and append them at your will:
<txp:etc_query data='<txp:category_list break="li" wraptag="ul" />'
replace="ul@@id=menu@role=navigation" />
or even with <txp:else /> if need:
<txp:etc_query data='<txp:category_list break="li" wraptag="ul" />'
replace="ul@@id=menu@role=navigation"
>
{ul}
<txp:else />
nada
</txp:etc_query>
Offline
Re: id in category list
etc wrote #289980:
as well as for each of ~30 tags having “wraptag”
Yeah, I know what you mean. I’ve tentatively done it anyway the way colak suggested because it saves unnecessary markup and means extra conditionals or plugins are not required to detect those situations where you want to entirely omit the markup if there’s no list content (unlikely for section_list, but possible for category_list).
But I’m not altogether comfortable with attribute bloat like this, and the whole ‘conditional attribute’ thing (attributes that are ignored depending on other attributes) is not ideal to make clear in documentation.
Edit: While a built-in etc_query-style solution for adding attributes would certainly cut down on attributes, the syntax isn’t exactly end-user friendly so if we were to go that route, we’d need something simpler that could add arbitrary atts to any <tag> (HTML or Txp). Suggestions welcome.
Last edited by Bloke (2015-04-14 09:46:00)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: id in category list
Hi Stef and Oleg
I might be wrong here but isn’t the nav role="navigation" usually wrapping the ul?
so we would have something like
<nav role="navigation" class="myclass" id="myid">
<txp:section_list wraptag="ul" break="li" html_id="menu" />
</nav>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: id in category list
colak wrote #289983:
isn’t the
nav role="navigation"usually wrapping theul?
Normally yes, unless you decide not to use unordered lists, for whatever reason:
<txp:category_list wraptag="nav" break="div" />
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: id in category list
Bloke wrote #289984:
Normally yes, unless you decide not to use unordered lists, for whatever reason:
<txp:category_list wraptag="nav" break="div" />...
I can not think of one but point made:)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: id in category list
colak wrote #289985:
I can not think of one
When doing hand-coded stuff on list elements, it can be useful to do the inner portion without Txp meddling:
<txp:section_list wraptag="nav" break="ul">
<li<txp:if_section name="about, blog"> class="static"</txp:if_section>><txp:section link="1" /></li>
</txp:section_list>
In such cases, using the spare ‘wraptag’ as the nav container makes sense to save other markup. But if you were using role then this approach wouldn’t work as there’s no native way to inject that attribute.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: id in category list
I’m ok with html_id, since it’s already here, but wouldn’t introduce any additional HTML attribute. They are quickly evolving and sometimes depreciated, hard to run after.
Bloke wrote #289981:
While a built-in etc_query-style solution for adding attributes would certainly cut down on attributes, the syntax isn’t exactly end-user friendly so if we were to go that route, we’d need something simpler that could add arbitrary atts to any
<tag>(HTML or Txp). Suggestions welcome.
Question of habits/education. The txp itself is not extra user-friendly from the start, I saw few sites with one page template per article! The @attr notation is quite standard in XML, but someone could have a better proposal.
Offline
Re: id in category list
Just a side note, you don’t need to specify a role="navigation" on a nav tag anymore, since that is the default semantic role for that tag anyway.
If you can use a native HTML element [HTML5] or attribute with the semantics and behaviour you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so.
Offline