Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-08-20 11:44:08
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
menu of categories and months
Hello,
What i need i a menu of all the categories as first level and all the monts of the articles of that categorie as a second level.
What’s the best way to make this in Textpattern.
Regards,
Roelof
Offline
Re: menu of categories and months
Not tested, but if you only use Category1 then perhaps something like:
<txp:article_custom sort="Category1 ASC, Posted ASC GROUP BY Category1, Month(Posted)" />
And combine that with a form that does something like this:
<txp:if_different>
<txp:category1 /><br />
</txp:if_different>
<txp:posted format="%B" /><br />
Offline
Re: menu of categories and months
To add ruud’s post,
you can link to the month based article listings by using ?month
-get in the url, in example we get URL that resemples smthing like:
<txp:site_url />?month=<txp:posted format="%Y-%m" />
And so we can get something like by expanding ruud’s form:
<txp:if_different>
<txp:category1 title="1" /><br />
</txp:if_different>
<a rel="nofollow" href="<txp:site_url />?c=<txp:category1 />&month=<txp:posted format="%Y-%m" />"><txp:posted format="%B" /></a>
Offline
#4 2008-08-20 13:49:43
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: menu of categories and months
Thank you for the tips.
Tonight i will try out your suggestions.
I have now 4 categories : zwangerschap, 1e levensjaar, 2e levensjaar en 3e levensjaar.
Regards,
Roelof
Offline
#5 2008-08-20 15:23:20
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: menu of categories and months
Ruud,
It doesn’t work.
I get this error message:
tag_error <txp:article_custom sort=“zwangerschap ASC, Posted ASC GROUP BY zwangerschap, Month(Posted)” /> -> Textpattern Warning: Er is iets fout in de gebruikte syntax bij ‘GROUP BY zwangerschap, Month(Posted) limit 0, 10’ in regel 1
select *, unix_timestamp(Posted) as uPosted from textpattern where 1=1 and Status = 4 and Posted <= now() order by zwangerschap ASC, Posted ASC GROUP BY zwangerschap, Month(Posted) limit 0, 10 on line 81
Roelof
Offline
Re: menu of categories and months
If you’ve only used Category1 to associate those 4 categories you mention with articles, then you should use Category1 instead of zwangerschap in that tag.
Offline
#7 2008-08-20 16:12:50
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: menu of categories and months
Hello Ruud,
I changed it but the same error-message appear.
Roelof
Offline
Re: menu of categories and months
Are you sure you replaced both cases of ‘zwangerschap’ with ‘Category1’? If so, please post the error message.
Offline
#9 2008-08-20 16:48:17
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: menu of categories and months
the error message is : tag_error <txp:article_custom sort=“Category1 ASC, Posted ASC GROUP BY Category1, Month(Posted)” /> -> Textpattern Warning: Er is iets fout in de gebruikte syntax bij ‘GROUP BY Category1, Month(Posted) limit 0, 10’ in regel 1
select *, unix_timestamp(Posted) as uPosted from textpattern where 1=1 and Status = 4 and Posted <= now() order by Category1 ASC, Posted ASC GROUP BY Category1, Month(Posted) limit 0, 10 on line 81
Roelof
Offline
Re: menu of categories and months
Hmm… my mistake. GROUP BY should appear before ORDER BY, which can’t be done with article_custom.
Due to the specific way in which you’re using categories, there’s an alternative (use Posted DESC to reverse order).
<txp:article_custom sort="Posted ASC" listform="myform" />
listform:
<txp:if_different><txp:category1 /><br /></txp:if_different>
<txp:if_different><!--<txp:category1 />--><txp:posted format="%B" /><br /></txp:if_different>
Dirty, but should work ;)
The category1 tag inside HTML comments ensures that if you have two articles in May, one in zwangerschap and one in 1e levensjaar, that May shows up below both categories instead of just under the first one.
Offline
#11 2008-08-20 18:07:03
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: menu of categories and months
Hoi Ruud,
This works.
Now i have to puzzle how to make a link of it so if someone choose a month all the articles of that month is displayed.
Roelof
Offline
Offline