Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-11-20 12:17:33

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

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

Let’s say I don’t want to do any deep structural changes with themes, but just want to change the ‘skin’ aspect of my theme, site-wide, on a seasonal basis, but without me having to manually switch it every three months.

How might that be approached? Not possible yet out of box?

Offline

#2 2019-11-20 12:44:47

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,456
Website GitHub

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

You’re probably best off doing this in your template via conditionals. You can probably use <txp:evaluate> to test if the date, for example, lies within a range and include a different Stylesheet based on the result.

Edit: I’ll leave it as homework for Oleg to provide the most efficient example ;)

Last edited by Bloke (2019-11-20 12:46:06)


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

Online

#3 2019-11-20 13:44:47

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

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

You can do it fairly simply with etc_date but I am sure evaluate can do something similar.

<txp:etc_if_date value="09-23 | 12-21" format="%m-%d">
	<txp:css format="link" media="" name="autumn" />
</txp:etc_if_date>
<txp:etc_if_date value="12-22 | 03-20" format="%m-%d">
	<txp:css format="link" media="" name="winter" />
</txp:etc_if_date>

Offline

#4 2019-11-20 13:58:08

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

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

I’ll second that. I’ve used etc_date for exactly this for years.

<txp:evaluate> may be more efficient, but etc_date works and is easy to use.

Offline

#5 2019-11-20 14:15:45

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

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

Thanks all.

Offline

#6 2019-11-20 20:09:49

etc
Developer
Registered: 2010-11-11
Posts: 5,210
Website GitHub

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

Bloke wrote #320143:

I’ll leave it as homework for Oleg to provide the most efficient example ;)

Sorry, my kids are my exclusive homework furnishers :-) A hint: you can register PHP date function via Advanced options for use in <txp:evaluate />.

Offline

#7 2019-11-20 22:56:35

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

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

etc wrote #320150:

Sorry, my kids are my exclusive homework furnishers :-)

Just like my house.

And thanks for the hint.

Offline

#8 2019-11-21 13:09:34

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

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

crib sheet

month-<txp:evaluate query='<txp:php>print date ('m');</txp:php>' />

will be displayed:
month-01
month-02
…………………..
month-11
month-12

<img src="month-<txp:evaluate query='<txp:php>print date ('m');</txp:php>' />.png" >

Last edited by singaz (2019-11-21 13:10:23)


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

Offline

#9 2019-11-21 13:52:06

etc
Developer
Registered: 2010-11-11
Posts: 5,210
Website GitHub

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

singaz wrote #320179:

<img src="month-<txp:evaluate query='<txp:php>print date ('m');</txp:php>' />.png" >...

Or even

<img src="month-<txp:php>print date ('m');</txp:php>.png" >

but we don’t consider <txp:php /> as “core” solution, right? However, if you register date function in PHP functions enabled in txp:evaluate pref, you will be able to call

<img src="month-<txp:evaluate query="date('m')" />.png" >

Offline

#10 2019-11-21 19:25:46

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

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

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

<txp:php>print date ('m');</txp:php>
or
print date ('m');
or
date ('m');
php

This does not work.

What syntax should be?

Last edited by singaz (2019-11-21 19:32:52)


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

Offline

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

etc
Developer
Registered: 2010-11-11
Posts: 5,210
Website GitHub

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
Registered: 2017-03-12
Posts: 150

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

Board footer

Powered by FluxBB