Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
Re: Auto-rotation of the skin layer of themes by dates/season/holidays?
Thanks all.
Offline
Re: Auto-rotation of the skin layer of themes by dates/season/holidays?
Offline
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
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
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