Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
The 'not' feature for tags (whatever it's called)
I really like this little addition to tags functionality, among all the others.
But this is just something I came across recently, if someone can explain it for curiosity’s sake.
I have three sections: default, about, articles. For the moment, about and articles use a common articles-based navigation (latest, next, prev, all…) and default uses nothing. (Yes, I know I could do away with the about section, but the site’s templates/code is minimal as is, so I like having some separation instead of conditional congestion for everything in one template.)
So in my common ‘opener’ form for templates, have this to negotiate the nav:
<txp:if_article_section name="articles,about">
<nav class="superior"><txp:output_form form="nav_articles" /></nav>
<txp:else />
</txp:if_article_section>
Works fine. I’m happy.
But it also seems like this should work too, if I understand it correctly. Just another way of saying the same thing:
<txp:if_article_section not name="default">
<nav class="superior"><txp:output_form form="nav_articles" /></nav>
</txp:if_article_section>
But it doesn’t work. I would expect to see no nav list markup output on the default section. Instead I get an non-styled version of the nav_articles form on the default page regardless.
Just curious why the difference?
Offline
Re: The 'not' feature for tags (whatever it's called)
I would expect this to work with any section except default (a.k.a. ""
). The reason is that there are no articles assigned to the default section.
Articles MUST be published to a Section and are shunted to the front page based on their ‘on front page’ checkbox. They are never actually assigned to the default
Section.
So your code is effectively saying: “Show me all articles except those that are assigned to the front page.” Since there are none assigned there, you’re getting the opposite, which is probably all articles. Or ‘no articles’ because Textpattern doesn’t quite get what you mean by “not front page”. I’m not sure which it does.
I’ve never tried this so I may be way off base, but that’s what I’d expect Txp to do based on how its article model works. Oleg or someone else might be able to chime in with a more concrete reason.
Last edited by Bloke (2018-10-29 12:18:24)
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
Re: The 'not' feature for tags (whatever it's called)
Thanks, Stef. That makes sense now. I’m probably the only dipwad that wouldn’t get that to begin with.
Offline
Re: The 'not' feature for tags (whatever it's called)
Not you. I had to think twice about it and talk to my rubber duck before it dawned on me. And I’m still not convinced it explains the specific behaviour you’re seeing – that may be a semi-bug because “not default” should be “every article” right? But you’re seeing no articles.
Mind you, it’ll depend on context, and if you’re viewing the front page itself then there may not be any article_section context, which might account for the unexpected output. Bit of a head scratch either way.
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
Re: The 'not' feature for tags (whatever it's called)
Bloke wrote #314803:
“not default” should be “every article” right? But you’re seeing no articles.
Really? It looks like Destry gets
an non-styled version of the nav_articles form on the default page regardless.
Which is normal for the reasons you explain. I suspect <txp:if_section />
will do the job here.
Offline
Re: The 'not' feature for tags (whatever it's called)
Oh yeah. I wrongly inferred that a non-styled Form meant no content inside it. As you were.
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
Re: The 'not' feature for tags (whatever it's called)
For the record, not
has no idea of the tags nature, it just switches true/false parts of <txp:else />
:
<txp:evaluate not query="2*2=5">
Right
<txp:else />
Wrong
</txp:evaluate>
outputs Right
(and Wrong
without not
).
Offline