Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2020-02-26 16:57:28

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

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

This was my very first attempt:

<txp:evaluate query="date('m')=2" >
Name 1, 28.02.2020
</txp:evaluate>
<txp:evaluate query="date('m')=02" >
Name 1, 28.02.2020
</txp:evaluate>
<txp:evaluate query="date('m') = 02" >
Name 1, 28.02.2020
</txp:evaluate>

This <txp:evaluate query="date('n')"/> displays the number 2.

This <txp:evaluate query="date('m')"/> displays the number 02.

But the container is not working. Something is missing.


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

Offline

#17 2020-02-26 16:59:12

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,252
Website Mastodon

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

an aside: <>Funny enough i was thinking of this last night. I recall a website from a feller in England that had a changing scene on his front page, depending on the time and i believe weather. The homepage consisted of an illustration of sheep grazing in a field with a house nearby, and the scene would change to reflect the time of day… from night to day to evening. It was cool. Not sure if the site is still in existence. He went on to get a Job at Apple and moved to Silicon Valley. </>


…. texted postive

Offline

#18 2020-02-26 17:00:31

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

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

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

This container does not work either


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

Offline

#19 2020-02-26 17:02:09

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,182
Website GitHub

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

singaz wrote #321931:

Something is missing.

You need == or ===. Those are comparison operators. An = on its own is setting a value. I was wrong here, sorry!

EDIT: I may have the syntax wrong. What happens if you do query="date('n') = 2" (i.e. without the quotes around the 2)?


TXP Builders – finely-crafted code, design and txp

Offline

#20 2020-02-26 17:36:34

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

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

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

It works.

But it is not right.

Quotes (' (' ') ' ) are repeated


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

Offline

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

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

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: 150

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: 150

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: 5,182
Website GitHub

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

#25 2020-12-05 15:39:00

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

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

New Years is soon.

My way to automatically change greeting text every day. Or an interval of days.

<txp:evaluate query="20201204 <= date('Ymd') and  date('Ymd') <= 20201231">
Image marked with desire 2020 Happy New Year
</txp:evaluate>
<txp:evaluate query="20201204 <= date('Ymd') and  date('Ymd') <= 20201205">
Congratulation in the outgoing year №1
</txp:evaluate>
<txp:evaluate query="20201206 <= date('Ymd') and  date('Ymd') <= 20201208">
Congratulation in the outgoing year №2
</txp:evaluate>

…..

<txp:evaluate query="20210101 <= date('Ymd') and  date('Ymd') <= 20210131">
Image marked with desire 2021 Happy New Year
</txp:evaluate>
<txp:evaluate query="20210101 <= date('Ymd') and  date('Ymd') <= 20210105">
Congratulation in the new year №1
</txp:evaluate>

……

Last edited by singaz (2020-12-10 00:58:53)


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

Offline

#26 2020-12-05 15:43:35

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

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

20201205 <= date(‘Ymd’)

2020 – this is the year
12 – this is the month
05 – this is the day

Last edited by singaz (2020-12-05 15:44:01)


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

Offline

Board footer

Powered by FluxBB