Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-04-14 05:58:17

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

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

#2 2015-04-14 07:09:47

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: id in category list

That might confuse people with Textpattern’s internal IDs though.

Offline

#3 2015-04-14 07:35:56

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

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

#5 2015-04-14 08:17:12

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: id in category list

That would work, please raise a GitHub issue for this.

Offline

#6 2015-04-14 08:45:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

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.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2015-04-14 09:24:52

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

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 wraptag was 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.

done


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#8 2015-04-14 09:34:20

etc
Developer
Registered: 2010-11-11
Posts: 5,192
Website GitHub

Re: id in category list

colak wrote #289979:

Also should this be implemented for the section_list tag 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

#9 2015-04-14 09:42:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

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.

Txp Builders – finely-crafted code, design and Txp

Offline

#10 2015-04-14 09:54:58

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

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

#11 2015-04-14 09:59:12

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

Re: id in category list

colak wrote #289983:

isn’t the nav role="navigation" usually wrapping the ul?

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.

Txp Builders – finely-crafted code, design and Txp

Offline

#12 2015-04-14 10:05:06

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

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

Board footer

Powered by FluxBB