Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I am so close to done i can taste it :) but I have run into one other problem when trying to show tabular view of created pages, sorted by month. I have successfully coded the page to show the pages in the correct fashion, but every entry is including the month header and the column labels.

This is what I have used once for each month, so the page has 12 instances of this code I just showed October for example:

Code: Select all
<cms:pages masterpage='sale_template.php' show_future_entries='1' limit='100' paginate='1' custom_field="sale_month==October | status==archive">

   <th class="monthheader" valign="top" colspan="6"><strong>October 2014</strong></th>
      <tr class="infoheader">
      <td>Date</td>
      <td>Time</td>
      <td>Address</td>
      <td>City</td>
      <td>Map</td>
      <td nowrap>Detailed Info</td>
      </tr>       
   <cms:if k_paginated_top>
      <cms:set current_column='1' />
   </cms:if>
   
   <cms:if current_column='1'>
      <tr class="info">
   </cms:if>
<cms:set start_month="<cms:date start_date format='F' />" />
   <cms:set end_month="<cms:date end_date format='F' />" />
   <td nowrap><cms:date start_date format='F j' />-<cms:if start_month=end_month><cms:date end_date format='j' />
   <cms:else /><cms:date end_date format='F j' />
</cms:if>
</td>
      <td nowrap>&nbsp;</td>
      <td nowrap>&nbsp;</td>
      <td><cms:show city /></td>
      <td>&nbsp;</td>
      <td><strong>Thank You!</strong></td>
    <cms:set current_column='6' />
   <cms:if current_column='6'>
      </tr>
   </cms:if>
   
   <cms:if k_paginated_bottom>
      <cms:if current_column lt max_columns>
         <cms:repeat count="<cms:sub max_columns current_column />">
            <td>&nbsp;</td>
         </cms:repeat>
         </tr>
      </cms:if>
   
      <cms:paginator />
   </cms:if>
   
   <cms:incr current_column />
   <cms:if current_column gt max_columns >
      <cms:set current_column='1' />
   </cms:if>

</cms:pages> 


This is what I end up with:

Image

How can I get the month and header row to show just once?
Figured it out and then some. Here is the code for just one month (November). Add this code again for each month (make sure to change the month name) Hope this helps someone else.

Code: Select all
<cms:pages masterpage='sale_template.php' show_future_entries='1' limit='100' paginate='1' custom_field="sale_month==November | status==current" order='asc' orderby='start_date'>

    <cms:if k_paginated_top>
    <cms:set current_row='1' />
    </cms:if>
   
   <cms:if current_row='1'>
  <th class="monthheader" valign="top" colspan="6"><strong>November 2014</strong></th>
      <tr class="infoheader">
      <td>Date</td>
      <td>Time</td>
      <td>Address</td>
      <td>City</td>
      <td>Map</td>
      <td nowrap>Detailed Info</td>
      </tr>
   </cms:if>   
   <cms:set current_row='2' /> 
    <cms:if current_row='2'>
       
   <cms:if k_paginated_top>
      <cms:set current_column='1' />
   </cms:if>
   
   <cms:if current_column='1'>
      <tr class="info">
   </cms:if>
<cms:set start_month="<cms:date start_date format='F' />" />
   <cms:set end_month="<cms:date end_date format='F' />" />
   <td nowrap><cms:date start_date format='F j' />-<cms:if start_month=end_month><cms:date end_date format='j' />
   <cms:else /><cms:date end_date format='F j' />
</cms:if>
</td>
      <td nowrap><cms:show times /></td>
      <td nowrap><cms:show address /></td>
      <td><cms:show city /></td>
        <cms:if address=''>
      <td><strong>Map</a></strong></td>
        <td><strong>Coming Soon!</strong></td>
       
        <cms:else />
        <td><strong><a href="https://maps.google.com/maps?q=<cms:show address /><cms:show city />+Michigan" target="_blank">Map</a></strong></td>
        <td><strong><a href="<cms:show k_page_link />">Details</a></strong></td>
       </cms:if>
    <cms:set current_column='6' />
   <cms:if current_column='6'>
      </tr>
   </cms:if>
   
   <cms:if k_paginated_bottom>
      <cms:if current_column lt max_columns>
         <cms:repeat count="<cms:sub max_columns current_column />">
            <td>&nbsp;</td>
         </cms:repeat>
         </tr>
      </cms:if>
   
      <cms:paginator />
   </cms:if>
   
   <cms:incr current_column />
   <cms:if current_column gt max_columns >
      <cms:set current_column='1' />
   </cms:if>

   </cms:if>
</cms:pages> 
This code definitely works, but i have a sneaky suspicion that it is overkill and the same thing could be accomplished with way less code. I'm guessing that you could use some php and create an array and then loop through that array to do the same thing without adding the above code 12 times (1 for each month). Unfortunately, writing php code is not in my wheel house. Anyone out there have any ideas to reduce the code for this?
3 posts Page 1 of 1
cron