Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-11-01 18:55:18

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,599
GitHub Twitter

[Solved] Category list and this_section TXP 4.8-dev

Within different section sharing the same page template, the this_section attribute for the <txp:category_list /> tag seems not working as expected (filtering only the categories for the current articles section):

<txp:category_list this_section="1" break=" " wraptag="span" class="m tc" active_class=""><txp:category title="0" link="1" class="b">#<txp:category title="1" /></txp:category></txp:category_list>

TXP 4.8-dev.

Last edited by Pat64 (2019-11-04 07:27:25)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#2 2019-11-01 19:23:48

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

Re: [Solved] Category list and this_section TXP 4.8-dev

Never used the attribute but according to the textbook,

Link to currently active section (overrides section attribute). Values: 0 (no) or 1 (yes). Default: 0

To me it only provides a link to the current section and it looks like might not be about category filtering. Maybe the following will work.

<txp:article_custom section="list,of,sections">
  <txp:category_list this_section="1" break=" " wraptag="span" class="m tc" active_class="">
    <txp:category link="1" class="b">#<txp:category title="1" /></txp:category>
  </txp:category_list>
</txp:article_custom>

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

Offline

#3 2019-11-01 19:54:50

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,599
GitHub Twitter

Re: [Solved] Category list and this_section TXP 4.8-dev

Doesn’t work either…

<txp:article_custom section='<txp:section />' limit="1">
  <txp:category_list this_section="1" break=" " wraptag="span" class="m tc" active_class="">
    <txp:category link="1" class="b">#<txp:category title="1" /></txp:category>
  </txp:category_list>
</txp:article_custom>

Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#4 2019-11-01 20:59:38

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

Re: [Solved] Category list and this_section TXP 4.8-dev

Thinking aloud, maybe the use of this_section="1" only works in the way you want it when txp:category_list is not used as a container tag (a bit like with active_class which you also have to handle manually when using as a container tag).

What happens if you shift the attribute to <txp:category, e.g.

<txp:category link="1" this_section="1" class="b"> …

TXP Builders – finely-crafted code, design and txp

Offline

#5 2019-11-01 21:11:21

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

Re: [Solved] Category list and this_section TXP 4.8-dev

jakob’s right. The this_section attribute on <txp:category_list /> only works if you use the tag as a single tag with no form/container. How will it alter or rewrite your custom content if you use a form or container? Even then, it may only work if you use a section attribute, otherwise it’ll just use the given section instead of flipping between front page and current section based on where it’s used.

We probably should mention this in the docs a bit more clearly.

EDIT: Having said that, the functionality of this tag changed significantly yesterday with the addition of per-section permlinks so it may be that this feature needs a little massaging yet.

Last edited by Bloke (2019-11-01 21:17:12)


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

#6 2019-11-01 21:26:53

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,599
GitHub Twitter

Re: [Solved] Category list and this_section TXP 4.8-dev

Sorry Stef but this:

<txp:category_list section='en' this_section="1" break=" " wraptag="span" class="m tc" />

Returns all categories available (the same if used as a container tag).


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#7 2019-11-01 21:35:26

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

Re: [Solved] Category list and this_section TXP 4.8-dev

this_section has nothing to do with which categories are selected. It is to do with how the links to the categories are created.

With this_section="1", the links will be made to the current section. So if you were in example.org/articles then your category links might be example.org/articles?c=animals (or with the new /section/category permlink schemes, proper clean mode links). If you also used the section attribute then the links would be made to that section instead of the current section (i.e. it ignores the this_section attribute).

With this_section="0" (default), the links will be made to the homepage. i.e. to example.org/category/animals

It is a bit of a confusing name for an attribute. Legacy, meh.

Does that clear things up?

Last edited by Bloke (2019-11-01 21:50:18)


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

#8 2019-11-02 19:25:39

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,599
GitHub Twitter

Re: [Solved] Category list and this_section TXP 4.8-dev

Sorry Stef for my late: I tried different uses whith the <txp:category_list /> tag.

Here is my results:

The links generated by this tag works perfectly (by filtering the categories attached to the currect section <txp:category_list section='<txp:section />' />).

The only problem I try to solve: never mind the section displayed, I got the entire list of all the categories created within the “Category” back-office panel even if no articles are attached to them).

What I wish to achieve: get the list of the only categories attached to articles for the current section.

Last edited by Pat64 (2019-11-02 19:28:38)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#9 2019-11-02 21:48:26

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

Re: [Solved] Category list and this_section TXP 4.8-dev

Something like this should do:

<txp:variable name="categories">
    <txp:article_custom section break=",">
        <txp:category1 />, <txp:category2 />
    </txp:article_custom>
</txp:variable>

<txp:category_list categories='<txp:variable name="categories" />' ... />

Offline

#10 2019-11-02 21:59:50

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

Re: [Solved] Category list and this_section TXP 4.8-dev

Pat64 wrote #319906:

What I wish to achieve: get the list of the only categories attached to articles for the current section.

Then you need trickery like Oleg suggests to constrain them. Remember, categories are section agnostic and can appear in any article, crossing section boundaries as filters.

The <txp:category_list> tag just outputs links to all the ones you list (or all cats if no filter is supplied). Then the section and this_section attributes govern how those links are made if you choose to let the tag generate them on your behalf. Using the tag with a form or a container will ignore these attributes.


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

#11 2019-11-03 18:37:49

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,599
GitHub Twitter

Re: [Solved] Category list and this_section TXP 4.8-dev

Thanks both ;)

I get what I expect adding a little amendment to Oleg’s advice:

<txp:variable name="categories">
    <txp:article_custom section='<txp:section />' break="," limit="99">
        <txp:category1 />, <txp:category2 />
    </txp:article_custom>
</txp:variable>

The included <txp:section /> is needed to filter the current section displayed.

Last edited by Pat64 (2019-11-03 18:39:20)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#12 2019-11-03 22:13:27

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

Re: [Solved] Category list and this_section TXP 4.8-dev

Pat64 wrote #319916:

The included <txp:section /> is needed to filter the current section displayed.

Glad you got it working, though valueless section attribute should have produced the same result.

Offline

Board footer

Powered by FluxBB