Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Auto-rotation of the skin layer of themes by dates/season/holidays?
singaz wrote #320189:
It turns out that can register the “time” and change the blocks during the day.
I like date_sunrise … but it works unreliably.
Offline
#14 2020-02-26 15:48:48
- singaz
- Member
- Registered: 2017-03-12
- Posts: 150
Re: Auto-rotation of the skin layer of themes by dates/season/holidays?
The task is a little harder and I do not know how to do it.
There is an article, a list of names with birthdays:
Name 1, 28.02.2020
Name 2, 01.03.2020
Name 3, 05.03.2020
Name 4, 12.03.2020
Name 5, 04.04.2020
Name 6, 15.04.2020
Name 7, 03.05.2020
Name 8, 09.05.2020
Every month you need to show the names of the people of the birthday.
How to automate?
My way is not working:
<txp:variable name="month" value="<txp:evaluate query='<txp:php>print date ('m');</txp:php>' />" />
or
<txp:variable name="month" value="<txp:evaluate query='date('m')' />" />
<txp:if_variable name="month" value="2">
Name 1, 28.02.2020
</txp:if_variable>
<txp:if_variable name="month" value="3">
Name 2, 01.03.2020
Name 3, 05.03.2020
Name 4, 12.03.2020
</txp:if_variable>
I know about the plugin etc_date. Maybe there is a way to do it without a plugin?
Last edited by singaz (2020-02-26 15:51:50)
Sorry my horror English. I’m learning textpattern, I’m learning English
Offline
Re: Auto-rotation of the skin layer of themes by dates/season/holidays?
singaz wrote #321923:
The task is a little harder and I do not know how to do it … Maybe there is a way to do it without a plugin?
The PHP manual for the date function says that m
= “Numeric representation of a month, with leading zeros” and n
= ‘Numeric representation of a month, without leading zeros’ so either:
- try your tests with
02
or03
, or - use:
date('n')
.
You might also want to try if you can skip the variable and go with evaluate (you’ll need to add “date” to the functions permitted for evaluate in Admin › Preferences › Advanced options):
<txp:evaluate query="date('n') == '2'">
Name 1, 28.02.2020
</txp:evaluate>
<txp:evaluate query="date('n') == '3'">
Name 2, 01.03.2020
Name 3, 05.03.2020
Name 4, 12.03.2020
</txp:evaluate>
(untested).
TXP Builders – finely-crafted code, design and txp
Offline
#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
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
Re: Auto-rotation of the skin layer of themes by dates/season/holidays?
singaz wrote #321931:
Something is missing.
You need I was wrong here, sorry!==
or ===
. Those are comparison operators. An =
on its own is setting a value.
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
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