Page 1 of 1
LISE – orderby not working with action="category"?
Posted: Tue Jan 07, 2020 10:18 pm
by 10010110
Trying to sort LISE items by creation date but nothing changes whatever I do.
Code: Select all
{LISEDownloads action='category' category='example1,example2' show_items=1 orderby='item_created|DESC'}
Is there something I’m missing?
Re: LISE – orderby not working with action="category"?
Posted: Tue Jan 07, 2020 11:41 pm
by DIGI3
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:
Code: Select all
<!-- 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:
Then create a summary template something like:
Code: Select all
{if $items|@count > 0}
{foreach from=$items item=item}
<li>{$item->title}</li>
{/foreach}
{/if}
Re: LISE – orderby not working with action="category"?
Posted: Wed Jan 08, 2020 9:07 am
by 10010110
Oh man, that’s more complicated than I expected. So, my category template looks like this:
Code: Select all
<!-- 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.
Re: LISE – orderby not working with action="category"?
Posted: Wed Jan 08, 2020 3:13 pm
by DIGI3
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.
Re: LISE – orderby not working with action="category"?
Posted: Thu Jan 09, 2020 3:28 pm
by 10010110
Thanks, it’s not quite as I hoped to achieve it but it works nicely.