Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#21 2016-11-03 09:24:49

etc
Developer
Registered: 2010-11-11
Posts: 3,580
Website

Re: Textpattern evaluation (dis)abilities

NicolasGraph wrote #302596:

That is probably why it is not obvious to understand why test wouldn’t be enough. Is there something you can do with insert that you couldn’t with test?

This will not work, because <txp:newer/older /> will be processed before <txp:article />, when the necessary pagination data is not yet set:

<txp:hide test="article">
    <txp:newer><txp:text item="newer" /></txp:newer>
    <txp:older><txp:text item="older" /></txp:older>

    <txp:text item="recent_articles" />
    <txp:article />
</txp:hide>

We could say “test first, then insert all the rest” by default, but then this would not work (or we’ll have to add variable to test or ignore):

<txp:hide test="article">
    <txp:variable name="limit" value="5" />
    <txp:article limit='<txp:variable name="limit" />' />
</txp:hide>

I’m not sure which way is more intuitive, open to all suggestions.

Offline

#22 2016-11-03 09:35:07

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Textpattern evaluation (dis)abilities

etc wrote #302601:

We could say “test first, then insert all the rest” by default…

+1

…but then this would not work (or we’ll have to add variable to test or ignore).

I would probably use ignore="variable".

Edited for clarity.

Last edited by NicolasGraph (2016-11-03 09:39:07)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#23 2016-11-03 09:59:29

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Textpattern evaluation (dis)abilities

If we remove insert and say “test first, then insert all the rest”, I’d see something like:

<txp:hide test="article" do="variable">
    <txp:variable name="limit" value="5" />
    <txp:article limit='<txp:variable name="limit" />' />
</txp:hide>

The ignore attribute would be renamed do.

Last edited by NicolasGraph (2016-11-03 10:01:21)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#24 2016-11-03 10:07:55

etc
Developer
Registered: 2010-11-11
Posts: 3,580
Website

Re: Textpattern evaluation (dis)abilities

NicolasGraph wrote #302603:

If we remove insert and say “test first, then insert all the rest”, I’d see something like:

<txp:hide test="article" do="variable">...

The ignore attribute would be renamed do.

Yes, maybe. Or process? I will think of it.

Offline

#25 2016-11-04 21:54:08

etc
Developer
Registered: 2010-11-11
Posts: 3,580
Website

Re: Textpattern evaluation (dis)abilities

This has nothing to do with the OP, but since <txp:hide /> discussion has started here, let’s continue. I’m about to merge what is suggested by Nicolas, just wanted to check if it’s ok.

New <txp:hide /> will accept test and process attributes and work like this:

<!-- neither process nor output, as before -->
<txp:hide>content</txp:hide>
<!-- firstly checks if there are some articles, then parses newer/older and outputs the block -->
<txp:hide test="article">
    <txp:newer /><txp:older />
    <txp:article />
</txp:hide>
<!-- processes variable, checks if there are some articles, then parses newer/older -->
<txp:hide test="article" process="variable">
    <txp:variable name="limit" value="5" />
    <h3>Articles paged by <txp:variable name="limit" /></h3>
    <txp:newer /><txp:older />
    <txp:article limit='<txp:variable name="limit" />' />
</txp:hide>
<!-- processes the code and sets variables, but hides the block from visitors -->
<txp:hide process>
    <!-- some comment for devs -->
    <txp:variable name="param1" value="1" />
    <!-- another comment for devs -->
    <txp:variable name="param2" value="2" />
</txp:hide>

All comments are welcome.

Last edited by etc (2016-11-05 10:43:00)

Offline

#26 2016-11-05 08:29:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,120
Website

Re: Textpattern evaluation (dis)abilities

Think I’m starting to grasp this conceptually now. This sounds ace.


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

#27 2016-11-05 10:36:55

etc
Developer
Registered: 2010-11-11
Posts: 3,580
Website

Re: Textpattern evaluation (dis)abilities

Bloke wrote #302672:

Think I’m starting to grasp this conceptually now.

Sure you do, it’s all about conditional processing/output. I’m not quite satisfied with attribute names (test and process), but can not find any better.

Offline

#28 2016-11-05 20:02:05

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,233
Website

Re: Textpattern evaluation (dis)abilities

In adi_if_content it’s not necessary to explicitly specify the tag to be tested, e.g.:

<txp:adi_if_content>
	<h1>Here's an article list</h1>
	<txp:article />
<txp:else />
	Nothing to say today
</txp:adi_if_content>

What would be the equivalent in the new txp:hide?

Offline

#29 2016-11-05 23:30:50

etc
Developer
Registered: 2010-11-11
Posts: 3,580
Website

Re: Textpattern evaluation (dis)abilities

gomedia wrote #302684:

What would be the equivalent in the new txp:hide?

<txp:hide test>
	<h1>Here's an article list</h1>
	<txp:article />
<txp:else />
	Nothing to say today
</txp:hide>

Offline

#30 2016-11-06 09:32:30

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Textpattern evaluation (dis)abilities

Hi, I’m just wondering… “semantically” should it be:

<txp:hide test>
	<h1>Here's an article list</h1>
	<txp:article />
<txp:else />
	Nothing to say today
</txp:hide>

or

<txp:hide test>
	Nothing to say today
<txp:else />
	<h1>Here's an article list</h1>
	<txp:article />
</txp:hide>

With adi_if_content it was logical to have to have the tested content in the first part of the code (adi_if_content means display if) but as we would now use hide, shouldn’t the tested content be in the else part (hide, else display…)?

Edited fo clarity.

Last edited by NicolasGraph (2016-11-06 11:55:39)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

Board footer

Powered by FluxBB