Example of Current Output:
*
* Article 1 (Category 1)
* Article 2 (Category 1)
*
* Article 3 (Category 2)
* Article 4 (Category 2)
I made a template override to this module that places the category title at the beginning of each group. The title retains its link.
Example of Override Output:
* Category 1
* Article 1
* Article 2
* Category 2
* Article 3
* Article 4
Simply put, the code chunk for placing (linked) category titles was moved to the LI of each first level UL, and then a variable and a WHILE statement were used to limit the output iterations created by the FOREACH statement that outputs the titles (with links) from $group as $item.
There is likely a smarter way of outputting linked titles, but I'm not savvy enough to figure out how to grab the category title element (only once) of $group as $item without using FOREACH.
FYI: There is a very simple one-line code chunk to make the titles display, by echoing $group_name, but then the category titles aren't linked.
Old Code (starting at line 16 [as of Joomla! v3.2.3])
Code: Select all
<li>
<ul>
<?php foreach ($group as $item) : ?>
<li>
<?php if ($params->get('link_titles') == 1) : ?>
<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
<?php echo $item->title; ?>
</a>
<?php else : ?>
<?php echo $item->title; ?>
<?php endif; ?>
<?php if ($item->displayHits) : ?>
<span class="mod-articles-category-hits">
(<?php echo $item->displayHits; ?>)
</span>
<?php endif; ?>
<?php if ($params->get('show_author')) :?>
<span class="mod-articles-category-writtenby">
<?php echo $item->displayAuthorName; ?>
</span>
<?php endif;?>
<?php if ($item->displayCategoryTitle) :?>
<span class="mod-articles-category-category">
(<?php echo $item->displayCategoryTitle; ?>)
</span>
<?php endif; ?>
Code: Select all
<li>
<?php $printgroupname="allow"; #limiter variable. actual value is moot, so long as it matches the following WHILE statement ?>
<?php foreach ($group as $item) : #start original category name code block ?>
<?php while ($printgroupname=="allow") : #interject an artificial limiter on $item iteration ?>
<?php if ($item->displayCategoryTitle) : ?>
<span class="mod-articles-category-category">
<?php echo $item->displayCategoryTitle; ?>
</span>
<?php endif; ?>
<?php $printgroupname="disallow"; #make the WHILE statement invalid, so as to prevent further $item iteration ?>
<?php endwhile; ?>
<?php endforeach; ?>
<ul>
<?php foreach ($group as $item) : ?>
<li>
<?php if ($params->get('link_titles') == 1) : ?>
<a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
<?php echo $item->title; ?>
</a>
<?php else : ?>
<?php echo $item->title; ?>
<?php endif; ?>
<?php if ($item->displayHits) : ?>
<span class="mod-articles-category-hits">
(<?php echo $item->displayHits; ?>)
</span>
<?php endif; ?>
<?php if ($params->get('show_author')) :?>
<span class="mod-articles-category-writtenby">
<?php echo $item->displayAuthorName; ?>
</span>
<?php endif;?>
<!--ORIGINAL CODE FOR CATEGORY TITLES-->
<?php /*foreach ($group as $item) : ?>
<?php if ($item->displayCategoryTitle) :?>
<span class="mod-articles-category-category">
<?php echo $item->displayCategoryTitle; ?>
</span>
<?php endif; ?>
<?php endforeach;*/ ?>