LISE limit display of items on page

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
brentnl
Power Poster
Power Poster
Posts: 493
Joined: Mon May 11, 2009 4:35 pm

LISE limit display of items on page

Post by brentnl »

I use 'lise' for a testimonial page, and on a sub-page I only want to display the last 4 items of a specific type and language. 'pagelimit=4' would be an option, but I also want to filter the items according to a specific checkbox. In my template I wrote an if/else statement for the checkbox, but pagelimit counts every item.

When for example only the 1st, 2nd, 6th and 8th item have the checkbox checked, only item #1 and #2 will be displayed with pagelimit=4, because the 6th and 6th item belong to page 2..

Code: Select all

{if $items|@count > 0}

<div class="row">
{foreach from=$items item=item}
	{assign var='salonhotel' value=$item->salon}
	{if $lang_parent == 'nl' && $item->taal == '1' && $salonhotel == '1'}
		<div>item info (language NL & salonhotel is checked)</div>
	{elseif $lang_parent == 'en' && $item->taal == '2' && $item->salon == '1'}
		<div>item info (language EN & salonhotel is checked</div>
	{/if}
{/foreach}
</div>

{/if}
User avatar
PinkElephant
Forum Members
Forum Members
Posts: 169
Joined: Fri Feb 06, 2009 2:08 pm

Re: LISE limit display of items on page

Post by PinkElephant »

I'm not very familiar with LISE but presumably you can iterate over all items with something along these lines...

Code: Select all

{$item_count = 0}
{$max_items = 4}
{foreach from=$items item=item}
	{if $item->salon == '1'}
		{if $lang_parent == 'nl' && $item->taal == '1'}
			<div>item info (language NL & salonhotel is checked)</div>
		{elseif $lang_parent == 'en' && $item->taal == '2'}
			<div>item info (language EN & salonhotel is checked</div>
		{else}
			{continue}
		{/if}
		{$item_count++}
		{if $item_count == $max_items
			{break}
		{/if}
   {/if}
{/foreach}
brentnl
Power Poster
Power Poster
Posts: 493
Joined: Mon May 11, 2009 4:35 pm

Re: LISE limit display of items on page

Post by brentnl »

Never heard of the {continue} and {break} functions, but it seems to workout, so that's great!

One last problem I got with this solution is that it also prints the counting of the items.. After each item it prints the number. So now i got;

Code: Select all

<div>
item
</div>
0
<div>
item
</div>
1
<div>
item
</div>
2

.....
Can't seem to find out which function is triggering the echoing of those numbers. I guess it has something to do with {$item_count++}; what are those '++' for?

EDIT

And is it possible to pass the 'max_items' variable within the call of LISE? Otherwise I would have to make a different template for different numbers (it depends on the page).

For Example;
{LISETestimonial template_summary='testimonial-salon' max_items='4'}
brentnl
Power Poster
Power Poster
Posts: 493
Joined: Mon May 11, 2009 4:35 pm

Re: LISE limit display of items on page

Post by brentnl »

brentnl wrote:....
EDIT

And is it possible to pass the 'max_items' variable within the call of LISE? Otherwise I would have to make a different template for different numbers (it depends on the page).

For Example;
{LISETestimonial template_summary='testimonial-salon' max_items='4'}
I solved this part with a little workaround; I removed max_items from the template and assigned the 'max_items' variable from outside the module, and then call LISE. Don't know if it's the most beautiful/practical solution, but it works ;D

Code: Select all

{assign var='max_items' value='5'}
{LISETestimonials template_summary='testimonial-salon'}
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: LISE limit display of items on page

Post by Jo Morg »

brentnl wrote:Can't seem to find out which function is triggering the echoing of those numbers. I guess it has something to do with {$item_count++}; what are those '++' for?
Yup, that tag will print and increment the variable... you probably want to assign it to something other var to prevent printing, something like {$foo=$item_count++} it will still increment it but prevent printing.
brentnl wrote:And is it possible to pass the 'max_items' variable within the call of LISE? Otherwise I would have to make a different template for different numbers (it depends on the page).

For Example;
{LISETestimonial template_summary='testimonial-salon' max_items='4'}
Nope, it will be ignored by CMSMS and by any module it's a security limitation, modules will only accept parameters known to them (typically documented on the module's help).
brentnl wrote:I solved this part with a little workaround; I removed max_items from the template and assigned the 'max_items' variable from outside the module, and then call LISE. Don't know if it's the most beautiful/practical solution, but it works ;D

Code: Select all

{assign var='max_items' value='5'}
{LISETestimonials template_summary='testimonial-salon'}
Just a heads up: that might stop working in the near future because of smarty var scopes and how LISE renders it's templates. That may change at some point in the future. You may want to use a global scope for that variable but lookout for possible overwrites on complex templates that might use the same variable in several sub-templates or module templates.

Code: Select all

{$max_items=5 scope=global}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
brentnl
Power Poster
Power Poster
Posts: 493
Joined: Mon May 11, 2009 4:35 pm

Re: LISE limit display of items on page

Post by brentnl »

Thanks! Everything is working properly now!
WWc
Forum Members
Forum Members
Posts: 20
Joined: Mon Aug 29, 2016 8:05 am

Re: LISE limit display of items on page

Post by WWc »

Hi

I'm having a problem with LISE where the pagelimit="3" option has stopped working in my tag {LISEGardens orderby='custom_enddate' template_summary='OGVfront' pagelimit="3"}

It was working until I used this within the summary template:

{if $smarty.now <= $item->fielddefs.enddate.value|@strtotime}

Could that be affecting it?

I've tried adding {$max_items=3 scope=global} instead (I'm assuming to the bottom of the summary template). But to no available.


Thanks in advance for any info that may help.


Have updated CMSms and all modules to latest versions.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: LISE limit display of items on page

Post by velden »

Note that using the pagelimit parameter will only 'give' 3 items (max) to the summarytemplate.

So if those 3 items don't fit your {if $smarty.now <= $item->fielddefs.enddate.value|@strtotime} there will be displayed zero items.

It shouldn't however influence the previous/next links (if properly implemented)
WWc
Forum Members
Forum Members
Posts: 20
Joined: Mon Aug 29, 2016 8:05 am

Re: LISE limit display of items on page

Post by WWc »

Thanks Veldon.

So, what I needed to do was count the number of loops that gave a successful result and then stop looping after I had three items.

This worked for me....

{if $smarty.now lte $item->fielddefs.enddate.value|@strtotime}

{counter assign=count}
{if $count eq 4}
{break}
{/if}


With this, I've been able to use the same LISE database to present information on three different pages.

Coming Events
Past Events and
and intro giving only the next three coming events on the home page.

Smarty is pretty good isn't it?
Post Reply

Return to “Modules/Add-Ons”