Forum for discussing general topics related to Couch.
6 posts Page 1 of 1
Is it possible to output the monthly heading in a list view i.e.

February 2013
----------------------------------
My Entry Title | Feb 2nd 2013
----------------------------------
More Entry Title | Feb 1st 2013
----------------------------------
January 2013
----------------------------------
My Entry Title | January 30th 2013
----------------------------------
More Entry Title | January 25th 2013
----------------------------------
Hi Entry Title | January 17th 2013
----------------------------------
December 2012
----------------------------------
Hi Entry Title | December 22th 2013


and maintain pagination, so perhaps limit to 25 entries per page?
Anyone? I can probably figure an easy way to do this with a few conditionals in the "calendar" but how about with the likes of a "News" landing page?
Hi Patrick,

Sorry for the delay in reply.

Coming to your query -
The easiest solution to this problem could be using cms:archives tag in tandem with cms:pages (where cms:pages uses the variables set by cms:archive that show the time-period) e.g.
Code: Select all
<cms:archives masterpage='news.php' >
    <b><cms:date k_archive_date format='F Y' /></b>
    <hr />
   
    <cms:pages masterpage='news.php' start_on=k_archive_date stop_before=k_next_archive_date>
        <cms:show k_page_title /> | <cms:date k_page_date format='M jS Y' />
        <hr />
    </cms:pages>
</cms:archives>

However, the cms:archives tag does not support pagination (which is your requirement).
So, we can take the following tack this time using only cms:pages:
Code: Select all
<cms:pages masterpage='news.php' paginate='1' limit='25'>

    <cms:if cur_period != "<cms:date k_page_date format='F Y' />" >
        <cms:set cur_period="<cms:date k_page_date format='F Y' />" />
        <b><cms:show cur_period /></b>
        <hr />
    </cms:if>
   
    <cms:show k_page_title /> | <cms:date k_page_date format='M jS Y' />
     <hr />
   
    <cms:paginator />
</cms:pages>

The logic is to keep a note of the current page's time-period. If it differs from the current period, output the time-period as a header and set it as the new period.
You can tweak this to put in your own markup.

Hope this helps.
KK, this works perfectly! I had to slot it into my table based view so I am going to use some conditionals to open and close the [table] so my pagination can sit outside it but remain inside the pages tags.
Hi KK,

Is this the best way to close my table, or is there a better solution? I was wondering if there is something like if_last_record so I didn't have to use the pages total, or does it really matteer?

Code: Select all
<cms:if k_count == k_paginate_limit || k_current_page == k_total_pages> 
                  </tbody>
               </table>
</cms:if>
                
             <cms:if k_paginated_bottom >
             <div class="pagination">
             <ul>
                 <cms:if k_paginate_link_prev >
                     <li><a href="<cms:show k_paginate_link_prev />">prev</a></li>
                 </cms:if>
                 <cms:if k_paginate_link_next >
                     <li><a href="<cms:show k_paginate_link_next />">next</a></li>
                 </cms:if>
             </ul>
             </div>
             </cms:if>   
Ignore previous post, the answer / solutions was staring me in the face - just put the closing table stuff inside the conditional for the pagination

Code: Select all
       <cms:if k_paginated_bottom >
             </tbody>
         </table>
       <div class="pagination">
       <ul>
           <cms:if k_paginate_link_prev >
               <li><a href="<cms:show k_paginate_link_prev />">prev</a></li>
           </cms:if>
           <cms:if k_paginate_link_next >
               <li><a href="<cms:show k_paginate_link_next />">next</a></li>
           </cms:if>
       </ul>
       </div>
       </cms:if>   
6 posts Page 1 of 1