Recordcount in related data always 0

pwouda

Joomla and Fabrik fan
Hi,

In my list of authors I enabled "list / data / related data" in order to show the number of articles that author has written in books, newspapers, magazines and essays. It looks like this:

https://leroy.noordoost.nl/welkom-webmaster/lijst-met-bronnen

As you can see the number of records is always zero. Sometimes this is correct, but also when an autor has written an article in an newspaper the count is stil zero.

In the Books form, there is a multiple select database-join element "author"

What do I have to do to make the count work?
The configuration of Related Data:
related-data-1.jpg

The result in the frontend:
related-data-2.jpg


Regards,
Peter
 
Last edited:
Related data is only working if your database join is single and you are using the primary key (usually "id[recommended]").
 
As an alternative you can manually create related data column(s) with calc element adding related count with a query and icons-links with some html. I've done that in many cases when I've needed more flexibility..
 
Related data is only working if your database join is single and you are using the primary key (usually "id[recommended]").

Thanks. So the count is always zero, but the link still works and shows the right records?
 
Thank you, I will dive in to it. Maybe a hint will help for the 'some html' part ;-)

As an alternative you can manually create related data column(s) with calc element adding related count with a query and icons-links with some html. I've done that in many cases when I've needed more flexibility..
 
Something like this in the calc element for related records:
Code:
$mydb = JFactory::getDbo();

$mydb->setQuery("SELECT COUNT(id) FROM yourtable WHERE some-element = '{rowid}'");
$related_records = $mydb->loadResult();

$mylink = "index.php?option=com_fabrik&view=list&listid=XX&Itemid=XX";
$mylink = JRoute::_($mylink);

return "<a href=".$mylink." target='_self'><i class="icon-list"></i> (".$related_records.")</a>";

Of course you need to figure out the correct query for you and adjust the link.
 
This solution works great! Thanks a lot.

Something like this in the calc element for related records:
Code:
$mydb = JFactory::getDbo();

$mydb->setQuery("SELECT COUNT(id) FROM yourtable WHERE some-element = '{rowid}'");
$related_records = $mydb->loadResult();

$mylink = "index.php?option=com_fabrik&view=list&listid=XX&Itemid=XX";
$mylink = JRoute::_($mylink);

return "<a href=".$mylink." target='_self'><i class="icon-list"></i> (".$related_records.")</a>";

Of course you need to figure out the correct query for you and adjust the link.
 
Back
Top