Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,473
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: 8,297
Website

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.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#13 2020-09-21 15:02:26

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,946
Website

Re: Categories list here, related article output over there

Destry wrote #325979:

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’m not sure you can usefully display the full article itself on the homepage (your and case) and the glossary section. What about this:

  • Use txp:article’s automatic context awareness for the glossary section using listform="glossary_listing" for the items in the list of entries and form="glossary_fullentry" for the individual glossary pages with the descriptions. If your address bar URL has a /glossary/?c=category-name that will automatically filter the list by category.
  • For the homepage, just output the category_list of the categories, e.g. all children of groups excluding groups and fashion links to href="<txp:site_url />glossary/?c=<txp:category />" so that when a category title is clicked on, it takes you to the filtered glossary list.

Something like:

<h1>Glossary</h1>
<txp:if_section name="default">
    <h2>Glossary categories</h2>
    <txp:category_list parent="groups" exclude="groups"  wraptag="ul" break="li" class="">
        <a href="<txp:site_url />glossary/?c=<txp:category />"><txp:category title /></a>
    </txp:category_list>
<txp:else />
    <txp:if_article_list>
        <txp:if_category>
            <h2>Entries under <txp:category title /></h2>
        <txp:else />
            <h2>Full glossary<h2>
        </txp:if_category>
    </txp:if_article_list>
    <txp:article listform="terms_alphabetical" form="term_entry"
                 wraptag="ol" break="li"  class="termslist"
                 sort="Title"                 
                 />
</txp:if_section>

I’ve forgotten, but there may be a better URL structure for section/category-name/ now since 4.8. I’m sure someone can chime in there.

If you very much want to filter via the homepage and not the glossary subsection, you can filter by articles directly on the homepage section if you:

  • in the section settings for the glossary section, allow that section to show on homepage, and
  • on the sections that shouldn’t display on the homepage (e.g. about, contact etc.), set them not to show on the homepage. You can still show them in a sidebar etc. if you want by explicitly calling them via an article_custom tag.

EDIT: corrected if_section section="…" attribute to txp:if_section name="…". Thanks for spotting that Oleg.


TXP Builders – finely-crafted code, design and txp

Offline

#14 2020-09-21 17:58:04

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,297
Website

Re: Categories list here, related article output over there

jakob wrote #325982:

I’ve forgotten, but there may be a better URL structure for section/category-name/ now since 4.8. I’m sure someone can chime in there.

Enclose the tags in <txp:article_custom section="glossary" form="" listform=""> as mentioned above. Your code seems lovely by the way:)


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#15 2020-09-21 19:34:20

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,946
Website

Re: Categories list here, related article output over there

colak wrote #325985:

Enclose the tags in <txp:article_custom section="glossary" form="" listform=""> as mentioned above. Your code seems lovely by the way:)

Hi Yiannis. I saw what you wrote before but I didn’t understand it 😳. I had read it as iterating over 10 articles in the glossary section ignoring forms but including the category_list each time? But maybe it’s a new trick I’ve not grocked yet.

But even reading over my own post, it looks too simple: I’m sure Destry’s case is more complex and there’s a reason he hasn’t gone for that option already. We’ll have to see what he says :-)


TXP Builders – finely-crafted code, design and txp

Offline

#16 2020-09-22 07:58:44

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

Re: Categories list here, related article output over there

jakob wrote #325982:

I’m not sure you can usefully display the full article itself on the homepage (your and case) and the glossary section.

Sorry, what that should have communicated was open the full article on the Glossary section, because at that point the reader is in the Glossary section:

Condition A:

  1. Arrive to homepage; see list of categories.
  2. Click a category
  3. Be taken to Glossary section; see list of articles related to category from step 2
  4. Click an article title in the filtered article list; see full article in Glossary section.

I haven’t thoroughly read through and thought about what you and Colak have shared since my last post. I’ll do that and test a few things then report back.

Last edited by Destry (2020-09-22 08:00:03)

Offline

#17 2020-09-22 08:23:32

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,946
Website

Re: Categories list here, related article output over there

Destry wrote #325990:

  1. Arrive to homepage; see list of categories.
  2. Click a category
  3. Be taken to Glossary section; see list of articles related to category from step 2
  4. Click an article title in the filtered article list; see full article in Glossary section.

Good, that’s what the code above should do :-)

And if your code is going to get increasingly complex over time, you can always simplify things for yourself by making two (or more) page templates, one for the homepage display and one for the glossary section (and another for a static “about” or “contact” page) …


TXP Builders – finely-crafted code, design and txp

Offline

#18 2020-09-22 08:30:25

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

Re: Categories list here, related article output over there

jakob wrote #325986:

Hi Yiannis. I saw what you wrote before but I didn’t understand it 😳.

Me either. An if_section on the section? A category_list nested inside an article_custom? No way I would have ever thought to do something like that. But, my grasp of Txp digresses with time (the wrong direction).

I had read it as iterating over 10 articles in the glossary section ignoring forms but including the category_list each time?

Just tested. That is exactly what happens. Though I thought Colak also meant use it on the homepage, but maybe what he meant by ‘front page’ is the default landing view of the Glossary section. I have not tried it there yet.

I also get a tag error saying listform="" is not a recognized attribute, but that’s probably because I didn’t put a form name in it. ;)

Still reviewing the other notes…

Offline

#19 2020-09-22 08:32:46

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

Re: Categories list here, related article output over there

jakob wrote #325991:

you can always simplify things for yourself by making two (or more) page templates, one for the homepage

That’s how it is already. I don’t do the one template for the entire kingdom thing. Brain can’t handle all that conditional voodoo.

Offline

#20 2020-09-22 08:57:18

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

Re: Categories list here, related article output over there

Here’s what I have at the moment… Btw, I use a 1:1 page to section structure. I should have clarified that early on. So if I say ‘homepage’ it means default section/page. If I say ‘Glossary’ it means a ‘glossary’ page assigned to a ‘glossary’ section.

Default (homepage) template:

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

If I understood Oleg correctly, that should pass a filtered article list to the Glossary section by the power of section="glossary".

Here is what’s on the Glossary template per Julian’s suggestion, though I’ve added in an example block, letter ‘A’ section, where full glossary would supposedly output…

<h1>Glossary</h1>
<txp:if_section section="default">
    <h2>Glossary categories</h2>
    <txp:category_list parent="groups" exclude="groups" wraptag="ul" break="li" class="">
        <a href="<txp:site_url />glossary/?c=<txp:category />"><txp:category title /></a>
    </txp:category_list>
<txp:else />
    <txp:if_article_list>
        <txp:if_category>
            <h2>Entries under <txp:category title /></h2>
        <txp:else />
            <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:if_category>
    </txp:if_article_list>
    <txp:article listform="terms_alphabetical" form="term_entry"
                 wraptag="ol" break="li"  class="termslist"
                 sort="Title"                 
                 />
</txp:if_section>

Behaviour…

Homepage:

  • Arrive at homepage
  • A category list displays as expected.
  • If a category link is clicked; taken to Glossary section but still see the same category list, no filtered articles.

Glossary:

  • Click ‘glossary’ link in main nav from homepage
  • Default landing view is same as above, a category list, nothing else.

So in both conditions, I’m getting the same categories list and no articles.

I’m also not getting any tag errors even though the behaviour is not desired. That would be a nice feature of Textpattern, actually: If a tag structure/nesting/whatever is not acceptable in Txp, it gives an error like ‘tags assemblage from opening to closing [tag name] tags is not acceptable structure’ Don’t know how that would be done, but it would take a little mystery out of the unexpected observations when they happen.

Last edited by Destry (2020-09-22 09:06:32)

Offline

Board footer

Powered by FluxBB