Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-09-18 15:17:13

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

Categories list here, related article output over there

My glossary architecture is shifting a bit and I’m floundering in Txp fundamentals, again. I need some help clearing the fog from those who do this in their sleep.

My main navigation has: About, Glossary, Bibliography

If a user clicks Glossary, they hop to that section and get the full enchilada: all available glossary titles in alphabetical order. So far so good.

I now want to use categories as an additional means to organize and browse titles, and this is what I’m scratching over:

  1. Output a categories list (e.g. trees, tools, timber, etc) on Homepage as links to sub-lists of glossary articles.
  2. When a category topic button is clicked, user is (conceptually speaking) whisked to the Glossary section and presented with a filtered list of titles in that category only.
  3. When a title in a filtered list is clicked, user is presented with the full article. (Exactly as if they clicked the title in the full glossary list.)

So the Glossary section needs to be a bit agile to respond to the different display contexts, if you see what I mean.

The part I’m puzzled over, at the mo, is step 2. What should the markup for the categories list look like to forward the user to the Glossary section? Of course I’m starting with this, which outputs the cats list fine, but the transferring elements are escaping me:

<txp:category_list categories="trees,timber,tools,structures,joints" break="li" wraptag="ul" class="groups" />

I guess the other approach more people favour is rotate everything in the default page, but I’m not kidding when I say I get a headache wasting hours trying to make sense of a long page of nested conditionals. Thus my splitting it across sections hope. Possible?

TIA

Last edited by Destry (2020-09-18 15:39:08)

Offline

#2 2020-09-18 17:06:59

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

Re: Categories list here, related article output over there

With txp 4.8.x you can emulate section specific categories when using /section/category/title URL pattern. This means that you can have urls like /glossary/trees/ and /glossary/trees/baobabs for example. If you are interested in such a markup you can see how it can be achieved here.


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 2020-09-18 18:18:28

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

Re: Categories list here, related article output over there

Hmmm… I think there might be something I need in here. I’ll rethink it over the weekend.

Last edited by Destry (2020-09-18 18:18:43)

Offline

#4 2020-09-18 19:27:24

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Re: Categories list here, related article output over there

colak wrote #325952:

With txp 4.8.x you can emulate section specific categories when using /section/category/title URL pattern. This means that you can have urls like /glossary/trees/ and /glossary/trees/baobabs for example. If you are interested in such a markup you can see how it can be achieved here.

I’m very interested in this, because I would like to use this for a project. But I’m a bit intimidated by this Textpattern-page of over 300 lines. :-)

Could you give me a hint where to look for the code how to emulate section specific categories when using /section/category/title URL pattern?


Prrrrrrrr

Offline

#5 2020-09-18 19:50:30

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

Re: Categories list here, related article output over there

Destry wrote #325949:

What should the markup for the categories list look like to forward the user to the Glossary section? Of course I’m starting with this, which outputs the cats list fine, but the transferring elements are escaping me:

<txp:category_list categories="trees,timber,tools,structures,joints" break="li" wraptag="ul" class="groups" />...

Have you tried adding this_section="1" attribute to your <txp:category_list />? That should add section filter to category URLs. Unless I’ve misunderstood the question, of course.

Offline

#6 2020-09-19 10:27:18

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

Re: Categories list here, related article output over there

etc wrote #325958:

Have you tried adding this_section="1" attribute to your <txp:category_list />?

I saw that, but I didn’t think it was relevant in my case.

I think what is confusing me is this notion that categories can be tied to sections. How is that possible? Categories are tied to articles, not sections. Or is that what is meant? It’s not that a category belongs to a section, but that the category is tied to articles that are themselves assigned to a section.

So in concept (no time to test yet), if I have a set of parent/child categories like this:

  • groups
    • timber
    • tools
    • trees
    • etc

I could use this on homepage to output a list of child categories?

<txp:if_section name="glossary">
<txp:category_list parent="groups" exclude="groups"  wraptag="ul" break="li" class="">
<txp:category title="1" link="1" />
</txp:category_list>
</txp:if_section>

And when a category was clicked in that list, it would send the user to the Glossary page and show only those articles assigned to that category?

That’s what I’m trying to do.

But the Glossary section will have three different contexts:

  1. The filtered list of sub-topic articles from above situation.
  2. Full glossary list (if user arrives to Glossary section by clicking ‘Glossary’ link in main nav).
  3. Full article view (when user clicks a glossary article title from either 1 or 2 in the Glossary section).

Last edited by Destry (2020-09-19 10:46:21)

Offline

#7 2020-09-19 10:53:41

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

Re: Categories list here, related article output over there

Of course, nothing outputs on the homepage because if_section is not appropriate there.

So I’m back to square one: How to use a category list on the home page that will display the articles in a given child category on a different section when a category link on the homepage list is clicked?

It seems like it should be easy, but I can’t figure it.

Last edited by Destry (2020-09-19 10:54:36)

Offline

#8 2020-09-19 12:36:02

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

Re: Categories list here, related article output over there

Does this work?

<txp:if_section name="">
<txp:category_list parent="groups" exclude="groups"  wraptag="ul" break="li" class="">
<txp:category title="1" link="1" />
</txp:category_list>
</txp:if_section>

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

Offline

#9 2020-09-19 12:46:59

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

Re: Categories list here, related article output over there

Destry wrote #325962:

I think what is confusing me is this notion that categories can be tied to sections. How is that possible? Categories are tied to articles, not sections.

Absolutely right, you’d need to cheat to tie categories to sections.

Or is that what is meant? It’s not that a category belongs to a section, but that the category is tied to articles that are themselves assigned to a section.

Adding section or this_section to <txp:category_list /> does not filter out categories, it just adds section chunk to their URL. For example, category links generated by <txp:category_list section="glossary" /> will be like /glossary/catname/. Clicking such a link will take you to a page of glossary articles with catname category.

Offline

#10 2020-09-21 08:53:22

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

Re: Categories list here, related article output over there

colak wrote #325965:

Does this work?

That’s what I had just tried in the post previous. But if_section doesn’t work like that on the homepage. At least not the way I was intending.

etc wrote #325966:

section="glossary"

Bingo! That was the ‘transferring’ mechanism I was looking for originally.

Now I am on to the next hurdle (I knew there would be another one).

If my nav is: Homepage, Glossary

And I’m attempting to try and achieve both of these conditions:

Condition A:

Homepage has list of categories that send a person to the Glossary section when a given category is clicked, and displays the filtered list of glossary articles for that category, and will display only the full article when a given article in the filtered list is clicked.

Condition B:

Glossary landing view, by default (i.e. if clicking the Glossary link in main nav) will show the full glossary (i.e. full set of glossary articles regardless of categories), and will display only a full article when a given article is clicked.

I can figure out either A or B by themselves, but not satisfy both situations.

I’ve tried variations of this, for exampe:

<txp:if_article_list>
  <h1>Glossary</h1>
  <h2>Full Glossary</h2>
  <section id="a" class="terms">
    <h2>A</h2>
    <txp:article_custom category="a" 
                        sort="Title"
                        wraptag="ol" 
                        class="termslist" 
                        break="li" 
                        form="terms_alphabetical" />
  </section>

  <txp:hide> Additional blocks for B through Z here </txp:hide>

<txp:else />

  <txp:if_article_category name='<txp:category />'>
    <h1>Glossary</h1>
    <h2><txp:category title="1" /> Entries</h2>
    <txp:article_custom sort="Title" 
                        wraptag="ol" 
                        class="termslist" 
                        break="li" 
                        form="terms_alphabetical" />

  <txp:else />
    <article><txp:article form="default" /></article>
  </txp:if_article_category>
</txp:if_article_list>

Is satisfying Conditions A and B even possible on the same Glossary section?

Offline

#11 2020-09-21 09:25:09

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

Re: Categories list here, related article output over there

I think the part I’m confused about now is what to use at the receiving end (Glossary section) when someone clicks a category link on the homepage (i.e. via <txp:category_list section="glossary" />) ?

etc wrote #325966:

category links generated by <txp:category_list section="glossary" /> will be like /glossary/catname/. Clicking such a link will take you to a page of glossary articles with catname category.

If I have this on the Glossary template, which satisfies default condition:

<txp:if_article_list>
  <h1>Glossary</h1>
  <h2>Full Glossary</h2>
  <section id="a" class="terms">
    <h2>A</h2>
    <txp:article_custom category="a" 
                        sort="Title"
                        wraptag="ol" 
                        class="termslist" 
                        break="li" 
                        form="terms_alphabetical" />
  </section>
  <txp:hide>Blocks B through Z not shown here</txp:hide>

<txp:else />
  <article><txp:article form="default" /></article>
</txp:if_article_list>

Then what needs added to that to make the following true as well when someone arrives via the homepage category?

Clicking such a link will take you to a page of glossary articles with catname category.

Last edited by Destry (2020-09-21 09:28:35)

Offline

#12 2020-09-21 09:47:39

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

Re: Categories list here, related article output over there

another possible way that it may work for the front page.

<txp:if_section name="">
<txp:article_custom section="glossary" form="" listform="">
<txp:category_list parent="groups" exclude="groups"  wraptag="ul" break="li" class="">
<txp:category title="1" link="1" />
</txp:category_list>
</txp:article_custom>
</txp:if_section>

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