Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2019-11-21 19:32:00

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

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

singaz wrote #320187:

How to register a function for <txp:evaluate/> ?

Like this

Offline

#12 2019-11-21 19:43:54

singaz
Member
From: Kyiv, Ukraine
Registered: 2017-03-12
Posts: 140

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

Oh yeah! Here is how it works.

Thanks.

I tried many options here .

But just “data” did not understand.

Everything just worked. It turns out that can register the “time” and change the blocks during the day.

Great opportunities open up.

I love textpattern!

Last edited by singaz (2019-11-21 19:54:49)


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

Offline

#13 2019-11-21 20:01:17

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

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
From: Kyiv, Ukraine
Registered: 2017-03-12
Posts: 140

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

#15 2020-02-26 16:04:46

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

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 or 03, 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
From: Kyiv, Ukraine
Registered: 2017-03-12
Posts: 140

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: 1,703
Website

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
From: Kyiv, Ukraine
Registered: 2017-03-12
Posts: 140

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: 3,937
Website

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
From: Kyiv, Ukraine
Registered: 2017-03-12
Posts: 140

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

Board footer

Powered by FluxBB