Count LISE Items
Posted: Wed Sep 11, 2024 2:37 pm
I have a LISE Instance with projects and another LISE instance for reports attached to each project.
On the LISE Project summary page i would like to display how many reports is attached to each project, and this summary template works but is very very slow:
Counting items in my LISE Reports instance i use a simple summary template:
I then thought testing an UDT quering the database directly if that would maybe speed things up. But i get no result even though the query gets a result if i run the select statement directly in the sql database:
What am i missing or doing wrong since the UDT gives no result? And is there another way to count and displays my reports in the project summary template?
On the LISE Project summary page i would like to display how many reports is attached to each project, and this summary template works but is very very slow:
Code: Select all
{* Module: LISEProjects Layout: listProjects *}
{if $items|@count > 0}
<div class="table-responsive overview">
<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">Weight Reports</th>
<th class="border-top-0"></th>
</tr>
</thead>
<tbody>
{foreach from=$items item=item}
<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>{LISEWeightReports template_summary='total' xs_project=$item->item_id}</td>
<td class="text-center"><a href="{$item->url}" class="button button-mini button-circle button-blumine">View</a></td>
</tr>
{/foreach}
</tbody>
</table>
</div>
{/if}
Code: Select all
{* Module: LISEWeightReports Layout: total*}
{$totalcount}
Code: Select all
$id = isset($params['id']) ? $params['id'] : '14';
$db = cmsms()->GetDb();
$query = "SELECT * FROM " . cms_db_prefix() . "module_liseweightreports_fieldval WHERE fielddef_id = '7' AND value LIKE" . $id;
$result = $db->Execute($query);
$num_rows = mysqli_num_rows($result);
echo $num_rows;