Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hi,

I have a clonable page called 'projects'.
Each one of this clonable pages must be on one of two category: "finished" or "ongoing". This is chosen trough a dropdown.

I need to output each group of four projects inside a <li></li>. A quick example:

Code: Select all
<h2>FINISHED</h2>
<ul>
<li>project 1</li>
<li>project 3</li>
<li>project 5</li>
<li>project 7</li>
</ul>
<ul>
<li>project 9</li>
<li>project 11</li>
<li>project 12</li>
<li>project 13</li>
</ul>
etc…

Code: Select all
<h2>ON GOING</h2>
<ul>
<li>project 2</li>
<li>project 4</li>
<li>project 6</li>
<li>project 8</li>
</ul>
<ul>
<li>project 10</li>
<li>project 12</li>
<li>project 14</li>
<li>project 16</li>
</ul>
etc…


Below I'm also giving a example on how I was trying to pull the information. Example for 'FINISHED' :

Code: Select all
<cms:pages masterpage='projects.php' orderby='weight' order='asc'>
<cms:if (category == 'FINISHED') && (k_count == '1') > <ul class="clearfix"> </cms:if>
</cms:pages>

<cms:pages masterpage='projects.php' orderby='weight' order='asc'>               
<cms:if (category == 'FINISHED') && (k_count == '1') ><li><cms:show project_name /></li></cms:if>   
<cms:if (category == 'FINISHED') && (k_count == '2') ><li><cms:show project_name /></li></cms:if>   
<cms:if (category == 'FINISHED') && (k_count == '3') ><li><cms:show project_name /></li></cms:if>   
<cms:if (category == 'FINISHED') && (k_count == '4') ><li><cms:show project_name /></li></cms:if>   
</cms:pages>

<cms:pages masterpage='projects.php' orderby='weight' order='asc'>
<cms:if (category == 'FINISHED') && (k_count == '1') > </ul> </cms:if>
</cms:pages>


And repeated this for multiple possibilities of course.

Question is: is there any way for me to do a k_count in order: 1, 2, 3, 4, 5 … but for each separate category?
I get a lot of gaps and unwanted results of course because k_count ouputs ALL 'projects' by numeric order and not just the ones inside a category.

I hope it's clear and really sorry for the huge post.
Couch rocks <3

Thank you so much.
F
Hi,

Some recipes for breaking up pages-listing into chunks are discussed in the following thread -
viewtopic.php?p=22909#p22909

I think the following bit of code, adapted from the thread mentioned above, should give you the kind of markup you want for one category ('FINISHED' in this example) -
Code: Select all
<cms:set my_max_columns='4' 'global' />

<cms:pages masterpage='projects.php' orderby='weight' order='asc' custom_field='category=FINISHED'>
    <cms:if k_paginated_top >
        <ul>
    </cms:if>
   
    <li><cms:show project_name /></li>
   
    <cms:if k_paginated_bottom || "<cms:not "<cms:mod k_count my_max_columns />" />" >
        </ul>
        <cms:if "<cms:not k_paginated_bottom />" >
            <ul>
        </cms:if>
    </cms:if>
</cms:pages>

You can duplicate the code changing just the category name to display the second group.

Hope this helps.
works like a charm KK, thank you so much!
You are welcome :) Glad I could help.
4 posts Page 1 of 1