Display number of database items and item sets in the home

hi all
we want to display in the home “theme/view/omeka/site/page/show.phtml” the number of items and item sets entered in the database.

any clues will be accepted

Tom

for now I made with a php call, maybe there is an api to do so more elegant

// get Numbers of items and items_set
$mysqli = new mysqli(“localhost”, “user”, “password”, “dbname”);

/* check connection */
if (mysqli_connect_errno()) {
printf(“Connect failed: %s\n”, mysqli_connect_error());
exit();
}

if ($result = $mysqli->query(“SELECT * FROM item”)) {
/* determine number of rows result set /
$itemNum = $result->num_rows;
/
close result set */
$result->close();
} else {
$itemNum = 0;
}

if ($result = $mysqli->query(“SELECT * FROM item_set”)) {
/* determine number of rows result set /
$item_setNum = $result->num_rows;
/
close result set */
$result->close();
} else {
$item_setNum = 0;
}

/* close connection */
$mysqli->close();

Simply getting a count of all the items could be done like this in a view:

<?php echo $this->api()->search('items', ['limit' => 0])->getTotalResults(); ?>

And similarly for other things like item_sets.

1 Like

thanks, works perfectly also with item_sets