Page 1 of 1

Mod_Articles_Categories - Show each category image

Posted: Thu Apr 18, 2019 1:56 pm
by pred000
Hello, what's the proper way to call categories image when using "Articles Categories" module?
I know that it needs to be an override on "mod_articles_categories/default_items.php" am i correct?

The current code is as follows:

Code: Select all

foreach ($list as $item) : ?>
	<li<?php if ($id == $item->id && $view == 'category' && $option == 'com_content') echo ' class="active"'; ?>> <?php $levelup = $item->level - $startLevel - 1; ?>
		<h<?php echo $params->get('item_heading') + $levelup; ?>>
		<a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($item->id)); ?>">
		<?php echo $item->title; ?>
			<?php if ($params->get('numitems')) : ?>
				(<?php echo $item->numitems; ?>)
			<?php endif; ?>
		</a>
		</h<?php echo $params->get('item_heading') + $levelup; ?>>

		<?php if ($params->get('show_description', 0)) : ?>
			<?php echo JHtml::_('content.prepare', $item->description, $item->getParams(), 'mod_articles_categories.content'); ?>
		<?php endif; ?>
		<?php if ($params->get('show_children', 0) && (($params->get('maxlevel', 0) == 0)
			|| ($params->get('maxlevel') >= ($item->level - $startLevel)))
			&& count($item->getChildren())) : ?>
			<?php echo '<ul>'; ?>
			<?php $temp = $list; ?>
			<?php $list = $item->getChildren(); ?>
			<?php require JModuleHelper::getLayoutPath('mod_articles_categories', $params->get('layout', 'default') . '_items'); ?>
			<?php $list = $temp; ?>
			<?php echo '</ul>'; ?>
		<?php endif; ?>
	</li>
<?php endforeach; ?>
Images should also have the respective link to them.
Please let me know how can this be achieved. :)

Thanks

Re: Mod_Articles_Categories - Show each category image

Posted: Wed Apr 24, 2019 9:29 am
by pe7er
mod_articles_categories/default_items.php will output all the data that is retrieved by its model.
With modules it's usually the helper.php that retrieves data from the database.
In this case it uses

Code: Select all

$categories = JCategories::getInstance('Content', $options);
An easy way to see what data is retrieved that you can use in your override, is to add the following to the top of your default_items.php

Code: Select all

echo"<pre>";
print_r($list);
echo"</pre>";

Re: Mod_Articles_Categories - Show each category image

Posted: Tue May 07, 2019 7:43 am
by pred000
I don't know about php, just the basic copy paste stuff. Can you kindly show me which code i need to add?
Thanks pe7er

Re: Mod_Articles_Categories - Show each category image

Posted: Tue May 07, 2019 9:38 am
by pe7er
pred000 wrote:
Tue May 07, 2019 7:43 am
Can you kindly show me which code i need to add?
Did you test the code from my previous post?

Re: Mod_Articles_Categories - Show each category image

Posted: Mon May 27, 2019 9:58 am
by pred000
I did and it broke the page. I'm sure that me being a php noob doesn't help in this situation. Anyway, i will not bother you anymore with this issue. Since i can get the same result with a custom plugin, that's what i will use for now, even though i would prefer to make it happen using Joomla, without much extra coding. You can close this thread and thanks for the time spent.