Page 1 of 1

LISE : Get Number Of Items In Instance

Posted: Tue Aug 16, 2016 7:26 pm
by Squire4Hire
Is it possible to get the number of items in a LISEInstance without being inside a summary or details template?

I'm trying to write some logic on my main page that will determine whether or not to display a message based on the number of items in the LISEInstance - but I can't figure out how to either determine if the Instance is empty or if the count = 0.

Any suggestions?

Thanks.

Re: LISE : Get Number Of Items In Instance

Posted: Tue Aug 16, 2016 9:02 pm
by Rolf
I use this in Uploads module.
Similar should work for LISE and other modules.

Create a summary template named i.e. 'itemcount' with content only {$items|@count}

Show the number in the frontend with {Uploads summarytemplate='itemcount'}

or attach it to a string like {$itemcount = "{Uploads summarytemplate='itemcount'}"}

Re: LISE : Get Number Of Items In Instance

Posted: Tue Aug 16, 2016 9:29 pm
by calguy1000
You can usually save multiple calls to the database, and lots of extra logic processing by simply doing something like this:

{ModuleCall assign='foo'}
{if !empty($foo)}{$foo}{else}MESSAGE{/if}

If you need the 'foo' stuff in a different template or in the body vs. the head etc. do a:
{ModuleCall assign='foo'}{$foo=$foo scope=global}

Or you can modify the module template to have that if statement/message in it and save even more processing.