Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-03-04 20:09:03

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Title based on Month

If I have say this: /articles/?month=2009-03

How can I get TXP to display the month in the title, so if I look at /articles/ the title would just be SITE NAMEARTICLES and if I go to the month the title would read SITE NAMEARTICLESMARCH 2009.

Thanks


~ Cameron

Offline

#2 2009-03-04 21:08:50

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,730
Website

Re: Title based on Month

You can use adi_gps to retrieve the url variable as I already suggested in an earlier post in your other thread. This makes a txp variable of each url variable, so you can test whether it exists using <txp:if_variable name="month">. If it exists, you can convert the date format from yyyy-mm to Monthname yyyy with a bit of php: <txp:php>echo date("F Y",strtotime($_GET["month"]));</txp:php>.

<txp:adi_gps />
<title><txp:site_name /> – <txp:section title="1" /><txp:if_variable name="month"> – <txp:php>echo date("F Y",strtotime($_GET["month"]));</txp:php></txp:if_variable></title>

TXP Builders – finely-crafted code, design and txp

Offline

#3 2009-03-04 21:22:37

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Title based on Month

Why does TXP need all that code to show a simple Month in the title? The code works great, but just seems long-winded to do something simple :/

Last edited by driz (2009-03-04 21:29:13)


~ Cameron

Offline

#4 2009-03-04 22:05:05

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Title based on Month

The fact that it needs “all that code” is probably the reason you needed a bit of help to achieve this, so why not just say “thank you, jakob”…

Offline

#5 2009-03-04 22:49:48

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,730
Website

Re: Title based on Month

driz, I am really exasperated with you. If I give you a few pointers (for example here) you say what’s the code?. If I or others gives you the code, you say tell me how it works. And if, like above, I give you the code, tell you how it works, go and test it myself and anticipate your next question (which would be, it busts when there’s no ?month=) you say it’s long winded.

I don’t know all this off the top of my head – I thought the question was interesting and googled. You could do the same if you were bothered.

This is the only bit that outputs the date in the url variable: echo date("F Y",strtotime($_GET["month"]));. I don’t think you’ll get it that much more compact. Go look up the php functions echo, date, strtotime and get variables to understand it.


TXP Builders – finely-crafted code, design and txp

Offline

#6 2009-03-05 02:10:30

keith
Member
From: Blyth, Northumberland, England
Registered: 2004-12-08
Posts: 199
Website

Re: Title based on Month

Els wrote:

so why not just say “thank you, jakob”…

That’ll be the day.


Keith
Blyth, Northumberland, England
Capture The Moment

Offline

#7 2009-03-05 13:32:13

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Title based on Month

I couldn’t look up the PHP functions, because I wasn’t aware I would need to do that, I assumed you’d be able to do something like this using TXP tags, seemed a little weird that it required both a plugin and some PHP to get a simple output of the month, but I guess that you do.

Anyways Thank you Jakob!


~ Cameron

Offline

Board footer

Powered by FluxBB