Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-12-19 13:48:36

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Archive per day with clean URL's

Hi all, it’s been a while!

So here’s the problem:

My URL’s look like this: http://mysite.com/notes/i-m-a-little-note
I’m displaying them grouped per day (by using <txp:if_different>), but would like to make the date clickable, so you can see which notes I posted that day.
I know this is easy if the URL’s would look like this: http://mysite.com/notes/2008/12/19/i-m-a-little-note
But they don’t, and it’s an existing site, so I can’t change them :(

Is there a build-in feature in TxP which does this, or do I need a plugin?


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

#2 2008-12-20 04:14:30

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Archive per day with clean URL's

ras_if_dates can filter by posting date with a conditional that is used in an article form much like if_different, except it looks for specific dates or time frames. It’s a plugin, but I don’t know of anything inside TXP proper that will look at dates that way.
Some examples here , these can be nested differently with 4.0.7 as well.

The download link is for the 4.0.7 plugin, there is a plugin for earlier versions on textcastle.com

Last edited by rsilletti (2008-12-20 04:18:23)

Offline

#3 2008-12-20 11:08:29

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Archive per day with clean URL's

maxvoltar wrote:

Is there a build-in feature in TxP which does this, or do I need a plugin?

Yes, there is: the month- and date-get parameter. For example, http://www.my-site.com/?month=yyyy-mm-dd will return posts in that specific day, where ?month= contains the posting time. For example:

  • ?month=2008
  • ?month=2008-07
  • ?month=2008-07-20

To link that day, you could use something similiar to this on your article form:

<a href="<txp:site_url />notes/?month=<txp:posted format="%Y-%m-%d" />"><txp:posted format="%Y-%m-%d" /></a>

You can compine that to your if_diffrent statement and voila, it’s there :)

Offline

#4 2008-12-20 11:27:34

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Re: Archive per day with clean URL's

Thanks Gocom! The lightweight solution I was looking for!


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

#5 2008-12-20 21:27:57

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Archive per day with clean URL's

Didn’t know month as a parameter would accept a day, will month as an attribute in an article tag work the same way?

Offline

#6 2008-12-22 00:03:31

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Re: Archive per day with clean URL's

Ok, I’m testing this little trick right now, but it’s acting really buggy. I can’t even predict which posts it’ll return…

Check:

Anyone? :)


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

#7 2008-12-22 00:31:09

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Archive per day with clean URL's

Sounds much like a time zone adjustment issue. I would have to look at how “month”, as a parameter, is handled inside publish.php to say for sure though.

Month as a value can be passed in by get in the format YYYY-MM-DD but when the query is built TXP appends a % to the value for formatting. If memory serves, and I don’t clearly remember how I altered the query to work for me the last time I did this, that query is where the problem with looking for an exact date value happens. I could be entirely off my mark here, so perhaps someone with stronger MYSQL skills could help. The query part itself goes this way:

" and Posted like '".doSlash($month)."%'  ";

Last edited by rsilletti (2008-12-22 00:59:04)

Offline

#8 2008-12-22 00:35:52

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Re: Archive per day with clean URL's

That could be possible, as I usually post things around midnight…
Will look into it!


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

#9 2008-12-22 07:55:52

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Archive per day with clean URL's

maxvoltar wrote:

That could be possible, as I usually post things around midnight…
Will look into it!

Definetly that is the reason. Easiest way probably is to not use offset or DST. Times are are saved to the database with out offset, and that makes difference when compared to the posting time that <txp:posted /> returns that uses offset.

What becomes to that query that rsilletti wondered; It just matches the results that have exact same needle somewhere there. That % sign just means that it matches an arbitrary number of characters.

Offline

#10 2008-12-22 13:51:52

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Re: Archive per day with clean URL's

Changed my settings to no offset and no DST, but the results are still buggy…


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

Board footer

Powered by FluxBB