Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#31 2020-09-22 13:23:40

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

Re: Categories list here, related article output over there

jakob wrote #326018:

I’m wondering whether you might be able to get around the whole 26 sets of article_custom tags by using txp:if_different in the listform you specify for txp:article, i.e. have the initial letter appear as interim headings. I must have a think about that.

Oleg to the rescue: he made a very neat suggestion here using txp:if_different.

Transferring that to your case, in your txp:article tag, you’d need sort="UPPER(Title)" instead of sort="Title" in the code above.

Then in your listform, you’d have:

    <txp:if_different>
        <h2 id="<txp:evaluate query='substring(<txp:title escape="quote" />, 1, 1)' escape="lower" />"><txp:evaluate query='substring(<txp:title escape="quote" />, 1, 1)' escape="upper" /></h2>
    </txp:if_different>
    <h3><txp:permlink><txp:title /></txp:permlink></h3>

For clarity, that should give you this kind of output:


<h2 id="a">A</h2>
<h3><a href="glossary/aadvark">Aardvark</a></h3>
<h3><a href="glossary/abacus">Abacus</a></h3>
…
<h2 id="b">B</h2>
<h3><a href="glossary/behemoth">Behemoth</a></h3>
<h3><a href="glossary/bricolage">Bricolage</a></h3>
…
<h2 id="c">C</h2>
…

If you want h3 + ul list + h3 + ul-list, you’ll have to investigate Oleg’s more complex example using breakby. Alternatively don’t use a list (ol isn’t the right type here anyway) and save yourself the pain fun.

That hopefully solves the interim glossary initial headings in the list of terms that are output and gives each an “id”. The a-z nav bar is still to be done.


TXP Builders – finely-crafted code, design and txp

Offline

#32 2020-09-22 13:47:24

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

Re: Categories list here, related article output over there

For the sake of being thorough, I really liked Oleg’s solution for a related problem to the glossary list that I was eventually going to come back to, which was to use a Write panel field (he used Keywords, but you could use a custom field) for a comma-separated list of ‘synonymous’ glossary terms, and these would be added as non-linked glossary entries with a ‘see [primary term]’ link in parentheses.

The idea was that there’s one primary article entry for a term, then all other related terms (e.g. colloquialisms, cultural differences, and in this case the same terms in French) are accounted for in the same article. The value of this in the back is to keep article overhead down, and in the front, to help direct people with different mental models to the term that has the definition.

Ex:

B
D
P
  • Porte-foret (see Drill)
V
  • Vilebrequin (see Brace)
  • . . .

Oleg has a blog post on it. That was some years back. Don’t know if that is possible now or if Txp is now capable of doing it natively, but it’s still highly desired in this project, and in relation to the full glossary list of alphabetically sectioned terms.

The original idea was to have the glossary appear in the homepage (because the whole site was the glossary), but that’s when the scope was only on traditional tools. I’ve since added terms for other groups (trees, timber, trades, people…). So now it makes sense to have the categories as discussed in this thread. Otherwise, same concept as originally imagined. The architecture is just a little different.

I’ll have to dig up the related posts, but I’m called to other duties now. Will be back later.

(The French thing will make more sense when you see an example of the site. It’s not a bilingual site, exactly; rather, most of my research was done using French literature and tools, so there’s simply a terms equivalent in French, and the editing is done from a native English speaker living in France. All part of the backstory.)

Had them bookmarked, in fact. In case you want more context:

Last edited by Destry (2020-09-22 14:14:22)

Offline

#33 2020-09-22 14:13:40

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

Re: Categories list here, related article output over there

Ah, I forgot all about that but now you mention it, it rings a bell. Sounds extremely clever and your project sounds fascinating too. Going to have to press on with my French lessons, I guess.


TXP Builders – finely-crafted code, design and txp

Offline

#34 2020-09-22 14:20:53

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,296
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 😳. 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.

Maybe I am misunderstanding but if the categories are enclosed into an article custom tag pointing to a section, their urls will follow the /section/category/ schema. If they are in the front page they may either link to ?c=trees or /default/trees/.


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

#35 2020-09-22 22:54:26

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

Re: Categories list here, related article output over there

jakob wrote #326020:

Oleg to the rescue: he made a very neat suggestion here using txp:if_different.

. . .

If you want h3 + ul list + h3 + ul-list, you’ll have to investigate Oleg’s more complex example using breakby.

I’m trying the latter approach because I want more layout control (as it works with my flexbox setup) over the glossary links as list items rather than headings. See markup below.

(ol isn’t the right type…)

I’m not arguing because I don’t have the specs memorized, but if a list is in alphanumeric order, doesn’t that make it an ordered list? That was my thinking. If I wanted lists in random order, then ul would seem to make sense, but if they need to be in a specific order, that seems like a job for ol. I’m happy to make it unordered if my logic is faulty.

That hopefully solves the interim glossary initial headings in the list of terms that are output and gives each an “id”. The a-z nav bar is still to be done.

I’m not interested in having a ‘a-z nav bar’ at this point, but I’ll keep that notion on ice. The glossary is written for people who don’t know what all the tools are or what they would be called — beginners, starting with me — so such a sub-nav would have limited utility anyway for that audince. And I want to encourage scrolling/scanning the list rather than blind-jumping around. I guess the ids in the heading don’t matter either, then.

As for solving the initial lettered headings, however, I think we’re almost there, but it’s not mapping out as you suggested anywhere.

Here are the relevant files in play…

Default (home) template:
<txp:category_list parent="groups" 
                   exclude="groups" 
                   wraptag="ol" 
                   break="li" 
                   class="">
<a href="<txp:site_url />glossary/?c=<txp:category />"><txp:category title /></a>
</txp:category_list>
Glossary template:
<txp:if_article_list>
    <txp:if_category>
        <h1 class="titre">Glossary</h1>
        <h2>Entries under <txp:category title /></h2>
        <txp:hide>Filtered list of articles magically appear here.</txp:hide>
    <txp:else />
        <h1 class="titre">Glossary</h1>
        <txp:article_custom sort="UPPER(Title)" 
                            breakform="glossary_sections"
                            breakby="glossary_sublists"> 
          <li><txp:permlink><txp:title /></txp:permlink></li>
        </txp:article_custom>
    </txp:if_category>
</txp:if_article_list>
<txp:article sort="UPPER(Title)" 
             breakby="glossary_sublists" 
             breakform="glossary_sections"  
             listform="terms_alphabetical" 
             form="default"
             class="termslist" />

In that last article tag, I’ve added the same breakby and breakform attributes because it makes the filtered list from the default page consistent in structure/appearance with the full glossary lists; i.e., term titles under their respective lettered headings.

The other two forms are thus:

  • listform="terms_alphabetical is just a wrapping permlink tag on a title tag inside lis.
  • form="default" is my full article view markup
glossary_sections form:
<section>
    <h3><txp:yield item="breakby" /></h3>
    <ol class="termslist"><+></ol>
</section>
glossary_sublists form:
<txp:evaluate query='substring(<txp:title escape="quote" />, 1, 1)' escape="upper" />

All of that is nearly giving me the two conditions below, as desired. I’ve got all boxes ticked (i.e. behaviour is working) except for the one in Condition B.

Condition A:

[x] Category list on homepage
[x] Click category link; taken to Glossary section where a sole list of associated glossary displays
[x] Click title in the filtered article list, full article opens.

Condition B:

[x] Click ‘Glossary’ link in main nav; full glossary list displays (default view) with terms grouped by their alphabetical heading [YES]
[ ] The full glossary with section-headed lists display, as desired? [YES and NO. The full glossary presentation is correct, but the full glossary outputs in duplicate, one after the other. I only want one full glossary]
[x] Click a link in the full glossary list; it opens the the full article by itself? [YES]

I’m guessing the fact that it’s close to working is probably a coincidence and not because it’s close to correct. Probably full of typos, too. There are no tag errors, though, and it’s in debugging mode.

Guidance at this point is welcome, because this new tag logic is indecipherable to me. All I can say is, if I change anything, it breaks either the homepage or the glossary page output in other ways. So I haven’t been able to find the secret sauce, or what is missing and where to get that one box ticked.

Last edited by Destry (2020-09-23 07:30:39)

Offline

#36 2020-09-23 07:28:47

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

Re: Categories list here, related article output over there

[ ] The full glossary with section-headed lists display, as desired? [YES and NO. The full glossary presentation is correct, but the full glossary outputs in duplicate, one after the other. I only want one full glossary]

I think all you need is to take out the article_custom tag that’s showing in the full list view because the txp:article tag (without _custom) at the bottom is already doing that part, i.e.:

<txp:if_article_list>
    <txp:if_category>
        <h1>Glossary</h1>
        <h2>Entries under <txp:category title /></h2>
        <txp:hide>Filtered list of articles magically appear here.</txp:hide>
    <txp:else />
        <h1>Glossary</h1>
    </txp:if_category>
</txp:if_article_list>
<txp:article sort="UPPER(Title)" 
             breakby="glossary_sublists" 
             breakform="glossary_sections"  
             listform="terms_alphabetical" 
             form="default"
             class="termslist" />

And you could shorten that a bit, seeing as you’re making the Glossary h1 appear either way to:

<txp:if_article_list>
    <h1>Glossary</h1>
    <txp:if_category>
        <h2>Entries under <txp:category title /></h2>
    </txp:if_category>
</txp:if_article_list>
<txp:hide>
    in article_list view txp:article lists the articles filtered by category else the full list.
    in individual_article view txp:article shows the full entry.
</txp:hide>
<txp:article sort="UPPER(Title)" 
             breakby="glossary_sublists" 
             breakform="glossary_sections"  
             listform="terms_alphabetical" 
             form="default"
             class="termslist" />

I’m not arguing because I don’t have the specs memorized, but if a list is in alphanumeric order, doesn’t that make it an ordered list?

Sounds like a plausible reason you suggested. It’s up to you :-)


TXP Builders – finely-crafted code, design and txp

Offline

#37 2020-09-23 07:54:01

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

Re: Categories list here, related article output over there

jakob wrote #326040:

I think all you need is to take out the article_custom tag that’s showing in the full list view

Huh. I thought I had tried that and it didn’t work, but it seems to be working fine now. Well spotted!

seeing as you’re making the Glossary h1 appear either way

Good one. I wanted that heading to appear on the different lists, but not on the individual article, which is why that slipped in there.

===

Cool. That all seems to be smooth now.

The next hat trick is to merge this working structure with Oleg’s synonymous terms functionality, or something natively similar.

And I’ll have to revisit images handling eventually, but that’s a different thread of worms.

Last edited by Destry (2020-09-24 08:14:42)

Offline

Board footer

Powered by FluxBB