Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-09-05 06:50:44

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

"Native" categories

After all these years I’ve finally accepted Txp’s default flow for handling categories, and thus the resulting, visible URLs (e.g. domain.tld/category/category-name), which eliminates need for any plugins or special mod_rewrite rules.

But I currently have it set up for one Section only — /articles. Here’s the categories list I use in any /articles section context (e.g. rail, bottom of page, whatever):

<txp:category_list parent="1-articles" exclude="1-articles" wraptag="ul" break="li" form="categories-list-items" />

And here’s what’s in the associated categories-list-items form:

<a href="/category/<txp:category />"><txp:category title="1" /></a>

And then the default page’s main content is built with this structure:

<txp:if_search>
SEARCH RESULTS CODE

<txp:else />

  <txp:if_category>
  CATEGORIES CODE

  <txp:else />

    <txp:if_author>
    AUTHOR PROFILES CODE

    <txp:else />

      REGULAR HOMEPAGE CODE

    </txp:if_author>
  </txp:if_category>
</txp:if_search>

If the context is a category, the CATEGORIES CODE part kicks in, giving whatever you wanted to show, which for me is an articles list:

<txp:article_custom section="articles" category='<txp:category section="articles" />' form="topic-results-list" sort="posted desc" wraptag="ul" break="li" />

That works fine for now, but what if I wanted to expand that for one or more additional sections besides /articles? In other words, what if the incoming category context was from a /docs section?

Obviously (or seemingly, if not so obvious) I’d have to adjust the initial category_list, or create a separate but similar form for use in the additional section(s).

But how would I alter the article_custom tag above to be conditional to the section context? Or is that even possible?

Offline

#2 2016-09-05 07:43:52

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

Re: "Native" categories

Destry wrote #301042:

Untested, but does this work?

<txp:article_custom section='<txp:section />' category='<txp:category section=''<txp:section />'' />' form="topic-results-list" sort="posted desc" wraptag="ul" break="li" />

Note the creative use of single and double-apostrophes instead of double-quotes.


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

#3 2016-09-05 07:50:10

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: "Native" categories

Haha… I think the hardest thing about Txp is not overthinking it. Thanks Sifu!

Offline

#4 2016-09-05 07:55:25

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,079
Website

Re: "Native" categories

Bloke wrote #301044:

Note the creative use of single and double-apostrophes instead of double-quotes.

Oh, that is interesting. I had never seen it used and certainly never thought about using that mix of double single-quote marks. Must add to my collection of snippets.

Is that documented somewhere?


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#5 2016-09-05 07:58:13

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

Re: "Native" categories

Destry wrote #301045:

I think the hardest thing about Txp is not overthinking it. Thanks Sifu!

You’re welcome, faithful Túdì!


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 2016-09-05 08:04:48

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: "Native" categories

I should clarify… I haven’t tested yet, but will as soon as I get some minutes. But I have faith in you, Master.

Offline

#7 2016-09-05 08:09:23

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

Re: "Native" categories

phiw13 wrote #301046:

Is that documented somewhere?

Sort of. The page needs work though, not least of which to fix the typos.


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 2016-09-05 08:41:59

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,079
Website

Re: "Native" categories

Bloke wrote #301050:

Sort of. The page needs work though, not least of which to fix the typos.

Thanks for that.
eh, yeah, typos… I sometimes wishes my English was passable enough to go playing grammar-and-typos nazi so I could eventually help out.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

Board footer

Powered by FluxBB