ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to build an archive?

August 20, 2008 4:20pm

Subscribe [2]
  • #1 / Aug 20, 2008 4:20pm

    jktress

    7 posts

    Hi,

    I’m trying to build an archive page that has the Month and year as a header, and the full title of each post below. Here’s what I was doing…

    {exp:weblog:month_links weblog="Posts"}
      
      <h3>{month} {year}</h3>
    <p>  <ul><br />
      {exp:weblog:entries weblog="Posts" orderby="date" sort="desc"}<br />
        <li><a href="http://{title_permalink=post/view}">{title}</a></li><br />
      {/exp:weblog:entries}<br />
      </ul><br />
      <br />
    {/exp:weblog:month_links}

    However I just read on the forums that nesting the entries inside the month_links tag probably isn’t the best way to go. Is there a reason why, and what is the preferred method? Also, what about pulling in entries from multiple weblogs in a single archive?

    Thanks!

  • #2 / Aug 20, 2008 6:32pm

    kirkaracha

    273 posts

    You could use date_heading and date_footer inside exp:weblog:entries:

    {exp:weblog:entries weblog="Posts"}
    
    {date_heading display="monthly"}
    <h2>{entry_date format="%F %Y"}</h1>
    <ul>
    {/date_heading}
    
    <li><a href="http://{title_permalink=post/view}">{title}</a></li>
    
    {date_footer display="monthly"}
    </ul>
    {/date_footer}
    
    {/exp:weblog:entries}

    That should give you headings with the month and year (August 2008), followed by a list of entries for each month. (See Date Variable Formatting for other date formats.)

  • #3 / Aug 20, 2008 9:44pm

    jktress

    7 posts

    thanks so much for your help, that worked great!

  • #4 / Aug 21, 2008 7:33am

    e-man

    1816 posts

    That is indeed sweet, I learn something new every day 😊 Bookmarked!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases