Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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
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
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
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:
- ?month=2008-11 (all entries from November, including one from December)
- ?month=2008-12-01 (returns nothing, although I posted 1 thing that day)
- ?month=2008-12-13 (returns everything from December 13th and December 14th)
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
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
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
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
Pages: 1