Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#21 2020-02-26 17:38:59

singaz
Member
Registered: 2017-03-12
Posts: 115

Re: Auto-rotation of the skin layer of themes by dates/season/holidays?

Thanks for the help!


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#22 2020-02-26 18:17:28

singaz
Member
Registered: 2017-03-12
Posts: 115

Re: Auto-rotation of the skin layer of themes by dates/season/holidays?

Continuation :)))

I am writing such text in an article

Birthday people:

<txp:evaluate query=‘date(‘n’) === 2 ‘ >
Name 1, 28.02.2020
</txp:evaluate>

Happy Birthday!

—————————————————

Display on the page:

This is the code:


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#23 2020-02-26 18:42:09

singaz
Member
Registered: 2017-03-12
Posts: 115

Re: Auto-rotation of the skin layer of themes by dates/season/holidays?

Oh my God! How does it work ???

Correctly so:

———————————

Birthday people:

<txp:evaluate query="date('m') = 02">

Name 1, 28.02.2020

</txp:evaluate>


<txp:evaluate query="date('n') = 2">

Name 1, 28.02.2020 , without quotes

</txp:evaluate>


<txp:evaluate query="date('n') = '2'">

Name 1, 28.02.2020 , quotes

</txp:evaluate>


<txp:evaluate query="date('n') = 3" >

Name 1, 28.02.2020

</txp:evaluate>

Happy Birthday!

—————————————

It is working.

But I don’t understand how.


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#24 2020-02-26 20:16:09

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

Re: Auto-rotation of the skin layer of themes by dates/season/holidays?

singaz wrote #321935:

<txp:evaluate query='date('n') === 2 ' >...

It works. But it is not right. Quotes (' (' ') ' ) are repeated

As far as I understand it, txp:evaluate either outputs something or it tests for a true or false condition. If you try the above but with 3 instead of 2, it still works, so the quoting is wrong and allowing the contents to be parsed regardless of whether the condition is true.

singaz wrote #321940:

Correctly so:

Birthday people:

<txp:evaluate query="date('m') = 02">

Name 1, 28.02.2020

</txp:evaluate>


<txp:evaluate query="date('n') = 2">

Name 1, 28.02.2020 , without quotes

</txp:evaluate>


<txp:evaluate query="date('n') = '2'">

Name 1, 28.02.2020 , quotes

</txp:evaluate>


<txp:evaluate query="date('n') = 3" >

Name 1, 28.02.2020

</txp:evaluate>

Happy Birthday!

Here you have the quoting correct and the tests are passing when you have the right combination, e.g. date('m') produces 02 so checking that you get 02 as the output works.

I forgot in the earlier post that txp:evaluate uses XPATH and not php for its evaluation, so the operators you need are these. It obviously seems to recognise the value with or without quotes.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB