Problems, need help? Have a tip or advice? Post it here.
9 posts Page 1 of 1
Hey there,

currently I'm having trouble to get this one right:

I have event-entries that are nested inside a subfolder called months which are nested inside a parent folder called years. My aim is to get those listed like that: Years (descending) | Months (descending) | Events (descending) - so I'll have the current year, month and event showing up on top. Here's a snippet of my code:

Code: Select all
<cms:folders masterpage="events/index.php"  hierarchical='1' extended_info='1'>
   <cms:if k_level_start ><ul id="archive-wrapper-<cms:show k_level />"></cms:if>
         
   <cms:if k_element_start ><li>
      <cms:if k_level='0' >
         <h1 class="year trigger"><cms:show k_folder_title /><span class="open">+</span></h1>
      </cms:if>
      <cms:if k_level='1'>
         <h3 class="month trigger"><cms:show k_folder_title /><span class="open">+</span></h3>
         <ul class="events-wrapper">
            <cms:pages masterpage="events/index.php" order="desc">
               <cms:if k_folder_name ><cms:set current_folder=k_folder_name /></cms:if>
               <cms:if k_page_foldername ><cms:set current_folder=k_page_foldername /></cms:if>
               <cms:if "<cms:is_ancestor parent=k_folder_name child=current_folder />" >
                  <li class="event-post">
                     <div class="post va <cms:show k_page_id />">
                        <a href="<cms:show k_page_link />">
                           <div class="teaser">
                              <div class="txt">
                                 <h4><cms:show k_page_title /></h4>
                                 <span class="date"><cms:date event_date format='l'/>, <cms:date event_date format='d.m.Y'/></span>
                              </div>
                           </div>
                           <img src="<cms:show event_preview_img />" alt="<cms:show k_page_title />" title=""/>
                        </a>
                     </div>
                  </li>
               </cms:if>
            </cms:pages>
         </ul>
      </cms:if>
   </cms:if>
         
   <cms:if k_element_end ></li></cms:if>
   <cms:if k_level_end ></ul></cms:if>
         
</cms:folders>


This one displays me the folders not in the order I intend to - but at least it displays me everything correctly. Now when I add order="desc" to the folders-tag it totally mashes me up the whole listing and entries.

Can anyone tell me what I'm missing here?

Thanks in advance!
Carr
It's either this or that.
"enumerate the folders in their hierarchical order." or "order the enumerated folders according to the following- name, title, id, count or weight."
To solve your issue - assign weight to folders, or start using 'folder' parameter for cms:pages, or start using cms:archive which is what seems to be perfect for your use-case (even can avoid folders totally).
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Thanks for your reply!

Each folder has a weight and I already tried to order them by their weight. The main problem is that if I change the ascending default order, couch displays me the folder and entries in a random order.

Here's an example what it looks like when I don't change the default order:

Code: Select all
<ul class="archive-wrapper-0">
   <li>
      <h1 class="year trigger">2016 (weight: 2016)</h1>
      <ul class="archive-wrapper-1">
         <li>
            <h3 class="month trigger">December (weight: 12)</h3>
         </li>
         <li>
            <h3 class="month trigger">November (weight: 11)</h3>
         </li>
         <li>
            <h3 class="month trigger">October (weight: 10)</h3>
         </li>
      </ul>
   </li>
   <li>
      <h1 class="year trigger">2017 (weight: 2017)</h1>
      <ul id="archive-wrapper-1">
         <li>
            <h3 class="month trigger">February (weight: 2)</h3>
         </li>
         <li>
            <h3 class="month trigger">January (weight: 1)</h3>
         </li>
      </ul>
   </li>
</ul>


That's cool so far...now I need to order the years in descending order. If I add order="desc" or orderby="weight" to the folders tag, couch displays me this code:

Code: Select all
<ul class="archive-wrapper-0">
   <li>
      <h1 class="year trigger">2017 (weight: 2017)</h1>
      <ul class="archive-wrapper-1">
         <li>
            <h3 class="month trigger">January (weight: 1)</h3>
         </li>
         <li>
            <h3 class="month trigger">January (weight: 1)</h3>
         </li>
      </ul>
   </li>
   <li>
      <h1 class="year trigger">2017 (weight: 2017)</h1>
      <ul id="archive-wrapper-1">
         <li>
            <h3 class="month trigger">February (weight: 2)</h3>
         </li>
         <li>
            <h3 class="month trigger">January (weight: 1)</h3>
         </li>
      </ul>
   </li>
</ul>


Any ideas where this behaviour comes from?

Thanks in advance!
Carr
This will work just fine.

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Folders' clonable='1' dynamic_folders='0' >

   <cms:folder name='y2017' title='2017'  >
            <cms:folder name='m201701' title='January'  />
            <cms:folder name='m201702' title='February' />
    </cms:folder>


   <cms:folder name='y2016' title='2016'  >
            <cms:folder name='m201601' title='January'  />
            <cms:folder name='m201602' title='February'  />
            <cms:folder name='m201603' title='March' />
    </cms:folder>
   
</cms:template>   


<cms:listfolders masterpage=k_template_name  hierarchical='1'/>

<?php COUCH::invoke(); ?>


Instead of <cms:listfolders /> feel free to place your code from previous posts. I used <cms:listfolders /> simply to illustrate that proper naming works.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Carr,

Indeed there seems to be a problem (the nested cms:pages tag appears to be messing up the parent cms:folders tag's sort order).

I'll study this matter and get back.
Thanks.
KK wrote: Carr,

Indeed there seems to be a problem (the nested cms:pages tag appears to be messing up the parent cms:folders tag's sort order).

I'll study this matter and get back.
Thanks.


Thanks! I was not quite sure whether it was me who wrecked up the code or couch was having trouble executing it.
Carr, I have just pushed a new commit to our GitHub repository - https://github.com/CouchCMS/CouchCMS/co ... 71edacbcae

Could you please try using the modified file (there is only one namely 'couch/folder.php') and let me know if that fixes the problem?
KK wrote: Carr, I have just pushed a new commit to our GitHub repository - https://github.com/CouchCMS/CouchCMS/co ... 71edacbcae

Could you please try using the modified file (there is only one namely 'couch/folder.php') and let me know if that fixes the problem?


Yes, it does! Thanks for the magic, KK!
You are welcome, Carr :)
Thanks for testing out the fix.
9 posts Page 1 of 1