Page 1 of 1

LISE categories not working when LISE Instance tag present

Posted: Tue Apr 30, 2024 12:41 pm
by webform
A strange problem I don't understand why is happening. Maybe someone can explain what is going wrong?

If I have both categories and another LISE Instance tag in a LISE summary template, categories stop working. However the first iteration in the loop does output the category.

My summary template:

Code: Select all

{if $items|@count > 0}

<div class="table-responsive">
	<table class="table table-striped">
		<thead>
			<tr>
				<th class="border-top-0">Project Number</th>
				<th class="border-top-0">Project Name</th>
				<th class="border-top-0">Project Type</th>
				<th class="border-top-0">Weight Reports</th>
			</tr>
		</thead>
		<tbody>
			{foreach from=$items item=item}
			{LISELoader item='category' force_array=1 value=$item->project_type assign='cats'}
			{$type= "{$cats|implode:','}"}
			<tr>
				<td class="fw-bold"><a class="link-dark" href="{$item->url}">{$item->project_number}</a></td>
				<td class="fw-bold"><a class="link-dark" href="{$item->url}">{$item->title}</a></td>
				<td>{$type}</td>
				<td>{LISEWeightReports template_summary='itemsCount' xs_project=$item->item_id}</td>
			</tr>
			{/foreach}
		</tbody>
	</table>
</div>

{/if}
However, if I change the way I retrieve categories, I can display categories and the result from the second LISE Instance tag:

Code: Select all

{LISELoader item='category' identifier='category_id' instance='LISEProjects' value=$item->project_type assign='type'}
I have tried inserting my LISE Instance tag in the default summary template and here categories also stop working!
Maybe someone can explain why it is so, so i can learn template logic?

Re: LISE categories not working when LISE Instance tag present

Posted: Tue Apr 30, 2024 12:44 pm
by magallo
Smarty processes template tags sequentially. If two tags or functions interact with each other or require similar resources, their order and mode of execution might interfere with each other.

Try this:

Code: Select all

{if $items|@count > 0}

<div class="table-responsive">
	<table class="table table-striped">
		<thead>
			<tr>
				<th class="border-top-0">Project Number</th>
				<th class="border-top-0">Project Name</th>
				<th class="border-top-0">Project Type</th>
				<th class="border-top-0">Weight Reports</th>
			</tr>
		</thead>
		<tbody>
			{foreach from=$items item=item}
			{* Fetch categories distinctly *}
			{LISELoader item='category' identifier='category_id' instance='LISEProjects' value=$item->project_type assign='type'}
			<tr>
				<td class="fw-bold"><a class="link-dark" href="{$item->url}">{$item->project_number}</a></td>
				<td class="fw-bold"><a class="link-dark" href="{$item->url}">{$item->title}</a></td>
				<td>{$type|implode:','}</td>
				<td>{LISEWeightReports template_summary='itemsCount' xs_project=$item->item_id}</td>
			</tr>
			{/foreach}
		</tbody>
	</table>
</div>

{/if}

Re: LISE categories not working when LISE Instance tag present

Posted: Tue Apr 30, 2024 12:52 pm
by webform
Thanks! That works perfectly.

Every day is an opportunity to learn something new. Although it can be a frustrating experience. ;D