Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-12-22 18:09:37

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

The tables below show the behaviour in 4.0.7 (and what it might become in 4.0.8) of the <txp:if_section> and <txp:if_category> tag on the frontpage and in category/section pages called ‘about’ and ‘other’ (as an example):

                                 | frontpage | s=about  | s=other 
------------------------------------------------------------------
<txp:if_section> 4.0.7           | TRUE      | FALSE    | FALSE
<txp:if_section> 4.0.8           | FALSE     | TRUE     | TRUE 
<txp:if_section name="">         | TRUE      | FALSE    | FALSE
<txp:if_section name="about">    | FALSE     | TRUE     | FALSE
<txp:if_section name="other">    | FALSE     | FALSE    | TRUE 
<txp:if_section name=",about">   | TRUE      | TRUE     | FALSE
<txp:if_section name=",other">   | TRUE      | FALSE    | TRUE
                                 | frontpage | c=about  | c=other 
------------------------------------------------------------------
<txp:if_category>                | FALSE     | TRUE     | TRUE
<txp:if_category name=""> 4.0.7  | FALSE     | TRUE     | TRUE 
<txp:if_category name=""> 4.0.8  | TRUE      | FALSE    | FALSE
<txp:if_category name="about">   | FALSE     | TRUE     | FALSE
<txp:if_category name="other">   | FALSE     | FALSE    | TRUE 
<txp:if_category name=",about">  | TRUE      | TRUE     | FALSE
<txp:if_category name=",other">  | TRUE      | FALSE    | TRUE

Leaving out the name attribute and setting the name attribute to an empty string doesn’t work consistently in both tags:

  • compare <txp:if_section> to <txp:if_category>: the former condition is true on the frontpage where there is no section while the latter condition is false on the frontpage where there is no category, but true for any valid category. The <txp:if_category> behaviour makes more sense.
  • compare <txp:if_category name="">, <txp:if_section name="">, <txp:if_category name=",about"> and <txp:if_section name=",about">. The last three are consistent in behaviour. When specifying an empty category or section, if you’re on the frontpage (no section/category), the condition is true. But <txp:if_category name=""> behaves differently, because that one is true currently if you’re on any valid category page. An empty category or section name could mean “any” or “none”. The latter makes more sense and is used in 3 out of 4 situations.

I think this can be fixed in the taghandler code.

For people upgrading from older versions, the old behaviour can be preserved by replacing tags in forms and pages in an update script like this (this isn’t perfect, but should cover the most common usage):
  • replace <txp:if_section> with <txp:if_section name="">
  • replace <txp:if_category name=""> with <txp:if_category>

Does the suggested behaviour change make sense?

Offline

#2 2008-12-22 18:21:59

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

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

I’m down with that. Much more consistent.

Do we assume then that you are considering dropping support for <txp:if_section="default">? Or will it behave:

                                        | frontpage | s=about  | s=other 
-------------------------------------------------------------------------
<txp:if_section name="default">         | TRUE      | FALSE    | FALSE
<txp:if_section name="default,about">   | TRUE      | TRUE     | FALSE
<txp:if_section name="default,other">   | TRUE      | FALSE    | TRUE

i.e. can be used as a synonym for ""?

EDIT or is ‘default’ a side-effect like the old ‘s’ was, and not actually officially supported?

Last edited by Bloke (2008-12-22 18:23:30)


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 2008-12-22 18:35:00

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

I don’t think users should use ‘default’ to indicate the frontpage, but support for ‘default’ shouldn’t be dropped (I don’t see a way to fix that automatically during upgrades).
‘default’ is used internally by TXP for that purpose (not a very good idea, but that’s how it is).

Offline

#4 2008-12-22 18:39:00

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

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

Fine by me; "" is far less typing :-)


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

#5 2008-12-22 20:07:20

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

That would be a nice fix, thank you. Until it came up in this thread I had never even suspected that <txp:if_section> did the same as <txp:if_section name="">

Offline

#6 2008-12-23 03:56:53

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

Re: time frame: I’d rather use 4.0.8 to fix open bugs and postpone substantial changes like that to 4.0.9, especially as theme authors would probably need to catch up with the proposed changes.

Offline

#7 2008-12-24 14:25:00

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

Like Els, I didn’t think <txp:if_section> or <txp:if_category> did anything. In fact, my own logic suggests they should both throw an error. That being the case all of my tags would have a “name” attribute so I don’t think anything you do would be a problem unless you stopped supporting the “default” section name. For some reason I thought this had recently become the norm, replacing “” but still supporting “”. I obviously misunderstood something there. :(


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#8 2008-12-24 14:50:47

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

What would change is the behaviour or <txp:if_section> (no name attribute) and <txp:if_category name=""> (name attribute set to an empty string). New behaviour would be the opposite of the old behaviour.

TextBook doesn’t cover either case. Neither in the explanation of the name attribute nor in the examples:

  • if_section: name = Comma-separated list of section names. For the default section, either use the text default or a single comma (for example, both name=”, other_section” and name=“default, other_section” are equivalent).
  • if_category: name = Comma-separated list of category names. Default is unset, which determines whether any category listing is being viewed.

Offline

#9 2008-12-29 05:29:26

truist
Plugin Author
From: Ohio, USA
Registered: 2004-11-09
Posts: 257
Website

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

Regardless of what is done (and I don’t think this would affect me, but I haven’t checked), could you please not use a patch version increment to introduce backwards-incompatible changes? I don’t understand why every new release is incremented as a patch anyway, but it just compounds the problem hugely if the “patches” introduce incompatibilities with earlier versions (as has already been done, but there’s nothing I can do about that now).

I’m sure it’s already been debated endlessly on the forums somewhere, but I’m hoping to head it off before it happens here.

Offline

#10 2008-12-29 13:49:00

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

This doesn’t affect upgrades of existing TXP installs because the necessary template/form updates are done automatically.

Offline

#11 2008-12-29 16:06:07

truist
Plugin Author
From: Ohio, USA
Registered: 2004-11-09
Posts: 257
Website

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

Ah, well I guess I spoke too soon. Thanks for clarifying!

Offline

#12 2009-09-10 05:58:49

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Proposal: fix behaviour of <txp:if_section> and <txp:if_category> tags

What’s the state of this proposal? Did it finally make it into 4.2.0? (wet mentioned it could be scoped for 4.0.9 release)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB