News archive using a pulldown list
On a site I am working on, I have this fabulously effective system set up where when users come to the newsreleases section of the site, they see the most recent article, and in the sidebar there is a handy select pull-down “News Archive” menu where they can view articles by month.
The select pull down code
<form method="get" name="newsarchiveform" action="<txp:site_url />newsreleases_archive"> <select name="month" onchange="this.form.submit()"> <option value="" selected="selected">Select Month</option> <txp:article_custom limit="9999" section="newsreleases_archive"> <txp:if_different> <option value="<txp:posted format="%Y-%m" />"> <txp:posted format="%Y %B" /> </option> </txp:if_different> </txp:article_custom> </select> </form>
The problem was that when an item was selected, the user would be taken to
/newsreleases_archive?month=2009-11, and all the articles that display were full articles, based on the
txp:article tag on the section page. I tried using
if_article_list, but Textpattern didn’t seem to recognize the output as an article list.
I wanted the results of that menu to return articles in a list format (i.e. using a form I have specifically designed for the display of that content with just titles, links and excerpts) and then when they click to view an article it displays the full article.
I figured the smoothest way to do this would be to have all the news release articles published to the newsreleases_archive section, which then displays the articles using my list-display form (and has the added benefit for the user of providing the url
/newsreleases_archive that will list all newsreleases to date), and then making my main
/newsreleases page display the most recent article from the newsreleases_archive section.
But of course, the
txp:permlink for each article then becomes
/newsreleases_archive/article-name, and so also displays using the same list-display format I’d set up. To get around this I used
txp:if_individual_article to get the permlink article to display the full content, and voila – works like a charm.
Page template code
<txp:if_individual_article> <txp:article /> <txp:else /> <txp:article limit="999" form="newsreleases_list" /> </txp:if_individual_article>
If you want to see it in action, you can check it out here (the site is not live yet): The News Releases section
Thanks to everyone at the forums who helped me put this together. I really couldn’t have done it without you!