Answer the question
In order to leave comments, you need to log in
How to display the number of favorite tickets in ModX?
It is necessary to display the number of tickets that the user added to it (to favorites).
It does not work through pdoMenu, since tickets are not child elements, but the result of the snippet.
In the database, the picture is as follows:
Here's how I first get only those ticket IDs whose id createdby is equal to the user id, and then count their number and output as a number?
Answer the question
In order to leave comments, you need to log in
<?php
if (empty($user)) {
$user = $modx->user->get('id');
}
if ($user == 0){
return false;
}
$q = $modx->newQuery('TicketStar', array('class' => 'Ticket', 'createdby' => $user));
$q->select('id');
if ($q->prepare() && $q->stmt->execute()) {
$count = $q->stmt->fetchAll(PDO::FETCH_COLUMN);
}
echo count($count);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question