Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-02-18 11:11:31

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

Override form also overrides display in article list

I’m not sure if this is a ‘problem’ or not, but it was new to me so bear with me:

Let’s say I have a couple of variants of the standard article form – e.g. article-with-image or article-with-lead-excerpt – that can be chosen as an override form.

In another page template I have a normal <txp:article form="article-single" listform="article-excerpt" … situation. I discovered that wherever those articles show in the article list view, the override form is shown, causing the excerpt list to suddenly show an entire article in the middle.

This wasn’t what I was expecting, but I guess it’s logical: the article_override also overrides the list view form.

You can control the output by providing if_individual_article and if_article_list sections in the override form itself … you just have to remember to do that!!

I’m not sure if this is desirable? In my typical list view case it wasn’t but maybe there are cases where a list form could vary too – I dunno you might set an article to be a big feature or a mini feature and have it display in the list view accordingly, or perhaps a standalone article (kind of like ‘thought for the day’) with no permlink…

So maybe this post is just a “public service announcement” for those who haven’t encountered that before. Opinions?


TXP Builders – finely-crafted code, design and txp

Offline

#2 2022-02-18 11:30:18

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 2,700
Website

Re: Override form also overrides display in article list

Unless I misunderstand you, there is the allowoverride="0" attribute to control that in article list context (docs).


Where is that emoji for a solar powered submarine when you need it ?

Offline

#3 2022-02-18 11:39:22

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

Re: Override form also overrides display in article list

Override forms are not something I use often but having looked at them a bit more now, I’m beginning to think they are underrated. You could use them quite effectively to make your own tumblr-style log with different post-types.

Tip 1 – Curate override form dropdown: One thing that has bothered me is that override form dropdown typically shows form templates that I’d rather users were not able to choose. There’s a way to curate exactly which forms should show:

  • First make sure “Advanced options” in Admin › Preferences › Admin is set to yes.
  • Visit Admin › Preferences › Advanced option and under Custom form template types add the following:
[articlevariant]
title="Article variants"

You can call these what you like but it seems names with underscores / dashes cause problems so I chose this. From then on, you’ll get Article Variant as another form type in Presentation › Forms.

  • Visit Admin › Preferences › Publish and under Override form types set this new form type to be used for the override form dropdown.

Now all you need to do is create/move your article variant forms into that form type.

———

Tip 2 – Use override forms as ‘option settings’ for your main article form: If your article variants are only slightly different to your main form, you can leverage the fact that you can now pass ‘settings’ to txp:output_form using txp:yield instead of creating an almost identical duplicate form.

For example, say you have an override form article-with-lead-excerpt:

<!-- override form : full article with intro paragraph --> 
<txp:output_form form="article-single" show_lead_excerpt="yes" />

And then in the regular article-single you have:

<txp:title wraptag="h1" class="entry-title" />

<txp:if_yield name="show_lead_excerpt" value="yes">
    <txp:excerpt wraptag="div" class="entry-lead" />
</txp:if_yield>

<txp:body />
…

(as a schematic outline)

In normal use, article-single will skip the if_yield container but if the form is output with a yield variable (e.g. via the override form), it will show the lead-in intro paragraph.


TXP Builders – finely-crafted code, design and txp

Offline

#4 2022-02-18 11:40:46

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

Re: Override form also overrides display in article list

phiw13 wrote #332776:

Unless I misunderstand you, there is the allowoverride="0" attribute to control that in article list context (docs).

Perfect! I should RTFM!

But I’m glad I asked – thanks for pointing that out.


TXP Builders – finely-crafted code, design and txp

Offline

#5 2022-02-18 22:20:57

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,744
Website GitHub

Re: Override form also overrides display in article list

Using override forms as sort of ‘block builder’ selectors for clients is something I had in the back of my mind when we tweaked the prefs to allow you to pick the type(s). I believe Phil does that approach in his recent theme template.

I wanted this to be used so you could decide, at publish time, if you wanted to write an article and have it displayed slightly differently to the norm. e.g. a “three-up gallery” type of post or a “teaser with excerpt” or any other combinations that you – as designer – want to extend to your clients.

With clever use of each ‘sub-template’ (override form), that then becomes a bit like a rudimemtary block builder, but without the Gutenberg baggage of having everything hard-coded at the article level. If you ever want to make a template change you retain the power to do so in one place, and have those changes reflected site-wide. The downside is you can only choose one ‘block type’ (override form) per article, and not build a page up from individual elements. But you could use custom fields to control what is displayed within each form.

See the GitHub issue for discussion.

The examples I thought up used custom field data to populate the content. Hadn’t thought of using conditionals in the template itself with <txp:yield> to switch behaviour. That’s clever.


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

Board footer

Powered by FluxBB