Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-11-17 07:15:38

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Month links of articles in current section

Hi all,

Just wondering if someone can please shed some light on how to create a list of links for each month articles have been posted, in a specific section.

Eg:

January
February
...
December

These would all be links and, when one is selected, an article_list would be rendered for all articles posted in that month.

I’ve looked at the faqs but can’t quite see how to reproduce what I’m after. I’ve also tried upm_date_archive and rss_suparchive, but neither of these seem to do the trick.

Any thoughts?


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#2 2009-11-17 08:51:53

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Month links of articles in current section

rss_suparchive will do that

EDIT, oh, just noticed you tried it already. It does do what you describe though I think. Something like:

<txp:rss_suparchive_menu mode="MONTH" section="your_section" linktosection="your_section" />

Last edited by pieman (2009-11-17 08:54:12)

Offline

#3 2009-11-17 09:23:24

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

Re: Month links of articles in current section

I would have thought the faq article that you linked to should work just fine (check the monthly articles example). Check your sort attribute in your article(_custom) tag. The if_different tag shows its content only when it differs from the previous article listed. If you’ve changed the sort attribute, for example, to sort="section asc" your articles won’t be listed by date and you’ll get lots of headers appearing in what seems to be the wrong order. You need sort="Posted desc" – that isn’t shown in the FAQ as it’s the default.

<txp:article_custom limit="999" section="fruit" sort="Posted desc">

   <!-- show month year -->
   <txp:if_different>
     <h3><txp:posted format="%B %Y" /></h3>
   </txp:if_different>

   <!-- article title and link -->
   <txp:permlink><txp:title /></txp:permlink><br />

</txp:article_custom>

If you want your list sorted by section and then date, you can try something like this (untested):

<txp:article_custom limit="999" section="fruit,veg,sweets" sort="section asc, Posted desc">

   <!-- show section title -->
   <txp:if_different>
     <h2><txp:section title="1" /></h2>
   </txp:if_different>

   <!-- show month year -->
   <txp:if_different>
     <h3><txp:posted format="%B %Y" /></h3>
   </txp:if_different>

   <!-- article title and link -->
   <txp:permlink><txp:title /></txp:permlink><br />

</txp:article_custom>

If you use ul-li or dl lists instead of h2 and br as in the example, you can then use jquery to show/hide each list of articles, so that they show or hide when you click on a heading – see this txptip for the basic principle.

I’m sure there are other ways of doing this too. IIRC rss_suparchive was supposedly very inefficient.

Last edited by jakob (2009-11-17 09:27:47)


TXP Builders – finely-crafted code, design and txp

Offline

#4 2009-11-17 11:54:20

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: Month links of articles in current section

@jakob,

Thanks for those examples. However, where I’m confused is in how to generate the output using the following:

<a href="what-to-put-here?">January</a>
<a href="what-to-put-here?">February</a>
etc, etc, etc.

where January (for example) is a link to all the articles in the current section that were posted in January.


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#5 2009-11-17 12:47:14

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

Re: Month links of articles in current section

Textpattern’s <txp:article /> tag supports month get variables.

[...]href="?month=2009-10"[...]

For example inside article context:

[...]href="?month=<txp:posted format="%Y-%m" />"[...]

Showing the articles can be done with the <txp:article /> and side navigation to the month with article_custom or a plugin.

<txp:article_custom>
	<txp:if_different>
		<txp:posted format="%Y-%m" />
	</txp:if_different>
</txp:article_custom>

Offline

#6 2009-11-17 12:53:55

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: Month links of articles in current section

@Gocom,

Thanks very much. I will dive into this tomorrow (currently just on midnight here!) :)


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#7 2009-11-17 17:00:45

frickinmuck
Member
Registered: 2008-05-01
Posts: 118

Re: Month links of articles in current section

I’m trying to do something similar, but I want a pulldown menu listing months where articles have been posted (if no articles were posted on a particular month, then that month wouldn’t appear). When an option is selected the user gets a list of articles/excerpts for all articles posted in that month. It seems like something that should be really easy to do, but I’ve tried for a couple of days to get this to work and I can’t find a solution that gives me what I need.


The AI does not hate you, nor does it love you, but you are made out of atoms which it can use for something else.

Offline

#8 2009-11-17 17:51:40

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

Re: Month links of articles in current section

frickinmuck wrote:

I’m trying to do something similar, but I want a pulldown menu listing months where articles have been posted (if no articles were posted on a particular month, then that month wouldn’t appear). When an option is selected the user gets a list of articles/excerpts for all articles posted in that month. It seems like something that should be really easy to do, but I’ve tried for a couple of days to get this to work and I can’t find a solution that gives me what I need.

Something like:

<form method="get" action="<txp:site_url />">
	<select name="month">
		<txp:article_custom limit="9999">
			<txp:if_different>
				<option value="<txp:posted format="%Y-%m" />">
					<txp:posted format="%Y %B" />
				</option>
			</txp:if_different>
		</txp:article_custom>
	</select>
</form>

Also requires standard <txp:article /> to show the articles on frontpage and on frontpage settings on for section you want to show on frontpage. Alternatively you can use only a one section or <txp:article_custom /> that is not context aware. Really simple.

Offline

#9 2009-11-17 21:00:17

frickinmuck
Member
Registered: 2008-05-01
Posts: 118

Re: Month links of articles in current section

Yes, I’d have thought it would be that simple, too, but it doesn’t work. It seems like a basic, basic feature that would be as easy to implement as txp : popup, but alas, it’s not. I’ve tried a variety of different approaches, including the example just posted, and I just can’t seem to get it to work.

It’s maddening that something so simple should be so difficult to do. Obviously this is a limitation of my own, not of Txp, but it amounts to the same result.


The AI does not hate you, nor does it love you, but you are made out of atoms which it can use for something else.

Offline

#10 2009-11-17 21:12:42

frickinmuck
Member
Registered: 2008-05-01
Posts: 118

Re: Month links of articles in current section

Eureka!! I finally manged to get it working. The secret was in the date format I had. I was using posted format=”%Y-%m”, when all I had to do was replace the hyphen with a slash and voila! Thanks so much for your help with this. Much appreciated.

<form method="get" action="<txp:site_url />newsreleases">
<select onchange="document.location=options[selectedIndex].value;"> <option value="" selected="selected">Select Month</option> 
<txp:article_custom limit="9999" section="newsreleases">
<txp:if_different>
<option value="<txp:site_url />newsreleases_archive/<txp:posted format="%Y/%m" />">
<txp:posted format="%Y %B" />
</option>
</txp:if_different>
</txp:article_custom>
</select>
</form></code>

Last edited by frickinmuck (2009-11-17 22:21:57)


The AI does not hate you, nor does it love you, but you are made out of atoms which it can use for something else.

Offline

#11 2009-11-17 21:19:01

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: Month links of articles in current section

frickinmuck,

Just out of interest how did you change your links to use a slash instead of the default hyphen?


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#12 2009-11-17 22:13:52

frickinmuck
Member
Registered: 2008-05-01
Posts: 118

Re: Month links of articles in current section

I got too excited about the fact that the menu was working, and failed to notice that the results list I’m getting on the page is not differentiating between the dates. So articles from October and November are showing up on the November page. Any ideas? My article list code is:

<!-- show the year --> 
<txp:if_different>
  <h1 class="datelist"><txp:posted format="%Y" /></h1>
</txp:if_different>
<!-- show the month -->
<txp:if_different>
  <h2 class="datelist"> 
  <txp:posted format="%B" /></h2>
</txp:if_different>
<br />
<!-- article -->
<txp:if_last_article><div> 
  <txp:else />
  <div class="list-item">
</txp:if_last_article>
<txp:permlink><h3><txp:title /></h3></txp:permlink>
<p class="date-small"><txp:posted /></p>
<txp:excerpt wraptag="p"/></div>

Last edited by frickinmuck (2009-11-17 22:16:51)


The AI does not hate you, nor does it love you, but you are made out of atoms which it can use for something else.

Offline

Board footer

Powered by FluxBB