开发者

Radiant: "Archive Month Index"

开发者 https://www.devze.com 2023-01-31 20:41 出处:网络
I trying to set up a simple blog with Radiant CMS and have a problem with the \"Archive Month Index\".

I trying to set up a simple blog with Radiant CMS and have a problem with the "Archive Month Index". I set it up as it is described on this weblog but I just can't get it to work.

The Code is the the same as the guy in the video st using. It's:

<r:archive:children:each>
  <div class="blog-post">
    <h3><r:link /></h3>
    <p>
      <r:content />
    </p>
  </div>
</r:archive:children:each>

...for the Archive Index.

However when I go onto the post/201开发者_StackOverflow社区0/12 site (or any other date) I get that amazing

StandardTags::TagError in SiteController#show_page
Recursion error: already rendering the `body' part.

...instead of the Index Page for the month. I just can't think of how I am rendering the body part twice.


I had exactly the same problem. So too do the default blog setups created by Radiant's installer.

The blog pages in Radiant looks something like:

+ Articles (Archive)
  |
  +- %B %Y Archives (Archive Month Index)
  |
  +- First Post
  | 
  +- Second Post
  |  
  +- Third Post

Everything under the Articles page seems to be included in the results returned by <r:archive:children:each></r:archive:children:each>.

This means that if the index page and the first post were created on Feb 02 2011, then the URL /articles/2011/02/ will throw this exception because the index page being processed to generate a page with a list of articles from Feb 2011 will recursively attempt to process itself.

The solution I wound up using is the <r:unless_self></r:unless_self> tags to winnow the page being processed (i.e. the index page) from the results of <r:archive:children:each></r:archive:children:each>.

An example non-crashing body page part for the index page would look something like this:

<r:archive:children:each order="desc">
  <r:unless_self>
    <div class="entry">
      <h3><r:link /></h3>
      <r:content />
    </div>
  </r:unless_self>
</r:archive:children:each>
0

精彩评论

暂无评论...
验证码 换一张
取 消