Advertisement

Displaying a list of materials in a list of categories

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
eLig
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Jul 02, 2024 3:12 pm

Displaying a list of materials in a list of categories

Post by eLig » Sun Sep 08, 2024 6:15 pm

Hi! Can you tell me how to modify the file "/components/com_content/tmpl/categories/default_items.php" correctly to get a list of category materials? Preferably with an example.

Advertisement
User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44681
Joined: Sat Apr 05, 2008 9:58 pm

Re: Displaying a list of materials in a list of categories

Post by Webdongle » Sun Sep 08, 2024 6:45 pm

What materials?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

eLig
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Jul 02, 2024 3:12 pm

Re: Displaying a list of materials in a list of categories

Post by eLig » Sun Sep 08, 2024 8:18 pm

Webdongle wrote: Sun Sep 08, 2024 6:45 pm What materials?
Articles

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44681
Joined: Sat Apr 05, 2008 9:58 pm

Re: Displaying a list of materials in a list of categories

Post by Webdongle » Sun Sep 08, 2024 8:35 pm

The order Articles are displayed (Category list and Blog) is set in the menu item. If your Template does not honour the settings contact the authors of the Template
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

User avatar
AMurray
Joomla! Master
Joomla! Master
Posts: 10270
Joined: Sat Feb 13, 2010 7:35 am
Location: Australia

Re: Displaying a list of materials in a list of categories

Post by AMurray » Sun Sep 08, 2024 9:30 pm

And a cautionary comment: don't modify core files - use Layout overrides if need be. But in this case I think the question is answered in @webdongles advice.
Regards - A Murray
General Support Moderator

eLig
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Jul 02, 2024 3:12 pm

Re: Displaying a list of materials in a list of categories

Post by eLig » Sat Sep 28, 2024 9:34 pm

Code: Select all

use Joomla\CMS\Factory;

$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);

$id_cats = array_column($this->items[$this->parent->id], 'id');

$query->select($db->quoteName(['id', 'title', 'catid']));
$query->from($db->quoteName('#__content'));
$query->where($db->quoteName('catid') . ' in (' .implode(",", $id_cats). ')');
$query->where($db->quoteName('access') . ' = 1');
$query->where($db->quoteName('state') . ' = 1');
$query->order($db->quoteName('ordering') . ' ASC');
$db->setQuery($query);
$ResQU = $db->loadAssocList();
I did it like this :)

Advertisement

Post Reply

Return to “Joomla! 5.x Coding”