CMS Made Simple Forums
https://forum.cmsmadesimple.org/

LISE – orderby not working with action="category"?
https://forum.cmsmadesimple.org/viewtopic.php?f=7&t=81857
Page 1 of 1

Author:  10010110 [ Tue Jan 07, 2020 10:18 pm ]
Post subject:  LISE – orderby not working with action="category"?

Trying to sort LISE items by creation date but nothing changes whatever I do.

\$1:
{LISEDownloads action='category' category='example1,example2' show_items=1 orderby='item_created|DESC'}


Is there something I’m missing?

Author:  DIGI3 [ Tue Jan 07, 2020 11:41 pm ]
Post subject:  Re: LISE – orderby not working with action="category"?  Topic is solved

As it's using the category array and not the item array, I don't think you can achieve this using parameters in a single module call. You could probably add a summary call to each category in the category template and apply the sorting there.

So your category template would be something like:
\$1:
<!-- categories -->
<ul>
{foreach from=$categories item=category}
  <li class="category-{$category->alias}">
    <a class="category-name" href="{$category->url}">{$category->name} ({$category->items|count})</a>
    {if $category->items|count > 0}
    <ul>
      {LISEtest category=$category->alias orderby='item_created|DESC' template_summary='list'}
    </ul>
    {/if}
  </li>
{/foreach}
<ul>
<!-- categories //-->


with the module call being:
\$1:
{LISEtest action='category'}


Then create a summary template something like:
\$1:
{if $items|@count > 0}
  {foreach from=$items item=item}
    <li>{$item->title}</li>
  {/foreach}
{/if}

Author:  10010110 [ Wed Jan 08, 2020 9:07 am ]
Post subject:  Re: LISE – orderby not working with action="category"?

Oh man, that’s more complicated than I expected. So, my category template looks like this:
\$1:
<!-- categories -->
<div class="downloads">
{foreach $categories as $category}
   {*$category|@print_r*}
   <!-- start loop{$category@iteration} -->
   {if $category->depth == 1}
      {if $category->prevdepth > 1 && $category@iteration != 1}
      </ul>
   </div>
   <!-- end category -->
      {/if}
   <div class="kategorie depth{$category->depth} prevdepth{$category->prevdepth}" id="{$category->alias}">
      <h3>{$category->menutext}</h3>
      {if $category@last}
      <div class="mitteilung hinweis">Momentan gibt es nichts zum Herunterladen.</div>
   </div>
         {continue}
      {/if}
      <ul>
   {else}
      <li class="depth{$category->depth} prevdepth{$category->prevdepth}">
      {if !empty($category->datei)}<a href="{uploads_url}/downloads/{$category->datei}">{/if}
         {$ext=$category->datei|pathinfo:$smarty.const.PATHINFO_EXTENSION|lower}
         {if $ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'gif' || $ext == 'tif' || $ext == 'tiff'}
            {CGSmartImage src="{uploads_url}/downloads/{$category->datei}" filter_resize="w,150" quality="86"}
         {/if}
         {$category->menutext}
      {if !empty($category->datei)}</a>{/if}
      {if !empty($category->beschreibung)}<div class="beschreibung">{$category->beschreibung}</div>{/if}
      {if !empty($category->datum)}<div class="datum">{$category->datum}</div>{/if}
      </li>
      {if $category@last}
         </ul>
      </div>
      <!-- last -->
      {/if}
   {/if}
<!-- end -->
{/foreach}
</div>
<!-- categories //-->

and this is what it looks like in reality:
https://tinyurl.com/yhdqqrma

(the two columns are two separate module calls; the important one is the one in the left column which calls several categories)

I’ve also defined a few custom fields. Basically what I need is sorting by date (specified in custom field) in descending order. ???

Author:  DIGI3 [ Wed Jan 08, 2020 3:13 pm ]
Post subject:  Re: LISE – orderby not working with action="category"?

I don't think it's as complicated as you might think. Just don't use show_items in the module tag, and add a module call (with default action, category, and your sort parameter) into your category template where you want to show items.

Author:  10010110 [ Thu Jan 09, 2020 3:28 pm ]
Post subject:  Re: LISE – orderby not working with action="category"?

Thanks, it’s not quite as I hoped to achieve it but it works nicely.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/