Mod_Articles_Categories - Show each category image

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
pred000
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Wed Apr 17, 2019 10:52 am

Mod_Articles_Categories - Show each category image

Post by pred000 » Thu Apr 18, 2019 1:56 pm

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
Last edited by toivo on Mon Apr 22, 2019 4:12 pm, edited 1 time in total.
Reason: mod note: moved to 3.x Coding

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22264
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Mod_Articles_Categories - Show each category image

Post by pe7er » Wed Apr 24, 2019 9:29 am

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>";
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content

pred000
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Wed Apr 17, 2019 10:52 am

Re: Mod_Articles_Categories - Show each category image

Post by pred000 » Tue May 07, 2019 7:43 am

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

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22264
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Mod_Articles_Categories - Show each category image

Post by pe7er » Tue May 07, 2019 9:38 am

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?
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content

pred000
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Wed Apr 17, 2019 10:52 am

Re: Mod_Articles_Categories - Show each category image

Post by pred000 » Mon May 27, 2019 9:58 am

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.


Post Reply

Return to “Joomla! 3.x Coding”