Exclude current article in Article categories module
Moderators: ooffick, General Support Moderators
Forum rules
-
- Joomla! Apprentice
- Posts: 19
- Joined: Wed Mar 09, 2016 12:00 pm
Exclude current article in Article categories module
So i'm doing an overwrite on the mod article categories (for displaying a list of articles in a certain category), but i want to exclude the current article shown in com_content. Any thoughts on how to get this done?
Last edited by toivo on Mon Jun 06, 2016 5:45 pm, edited 1 time in total.
Reason: mod note: moved to from 3.x Extensions to 3.x Coding
Reason: mod note: moved to from 3.x Extensions to 3.x Coding
-
- Joomla! Intern
- Posts: 83
- Joined: Thu Jan 18, 2007 5:35 pm
Re: Exclude current article in Article categories module
This is more or less covered within the module. You can style the active article with CSS-class active.
(Or use $item->active to exclude the article wihin your override.)
See code
...
<a class="mod-articles-category-title <?php echo $item->active; ?>"
...
(Or use $item->active to exclude the article wihin your override.)
See code
...
<a class="mod-articles-category-title <?php echo $item->active; ?>"
...
-
- Joomla! Apprentice
- Posts: 19
- Joined: Wed Mar 09, 2016 12:00 pm
Re: Exclude current article in Article categories module
Darn, that is actually a surprising simple solution, almost can't believe i didn't think of that. I simply added
to the main li in the module in a override and
to the css. Thanks for the suggestion!
Code: Select all
class="<?php echo $item->active; ?>"
Code: Select all
.category-module li.active {
display: none;
}
-
- Joomla! Apprentice
- Posts: 19
- Joined: Wed Mar 09, 2016 12:00 pm
Re: Exclude current article in Article categories module
Update: there is a downside to this.
I want to use the mod article categories to show 5 random items (and i rewritten it in such a way it shows intro-images and a button). So i set in the module the max items and random order. But now it gets messy: either max=5, it'll show 5 or 4 (cause when active item is among those 5 css will hide it), or max=6 and it'll show 5 (when active is among the items, but hidden) or 6, when active is not among the items shown. Get what i mean?
So i'll have to find another way to exclude, any thoughts?
what i got so far as override (don't mind the custom classes and still some stuff i dont need to remove)
I want to use the mod article categories to show 5 random items (and i rewritten it in such a way it shows intro-images and a button). So i set in the module the max items and random order. But now it gets messy: either max=5, it'll show 5 or 4 (cause when active item is among those 5 css will hide it), or max=6 and it'll show 5 (when active is among the items, but hidden) or 6, when active is not among the items shown. Get what i mean?
So i'll have to find another way to exclude, any thoughts?
what i got so far as override (don't mind the custom classes and still some stuff i dont need to remove)
Code: Select all
<?php
$num_items = count($list); ?>
<div class="category-module<?php echo $moduleclass_sfx; ?>">
<?php foreach ($list as $item) : ?>
<div class="ao-item" style="width: <?php echo round(100 / ($num_items - 1)); ?>%;">
<div class="alternatieven_overzicht <?php echo $item->active; ?>">
<a href="<?php echo $item->link; ?>">
<?php $images = json_decode($item->images); ?>
<div class="bekijkmask mask1"><img class="image_intro" src="<?php echo $images->image_intro; ?>" alt="<?php echo $images->image_intro_alt; ?>"/></div>
<?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; ?>
<?php if ($item->displayDate) : ?>
<span class="mod-articles-category-date">
<?php echo $item->displayDate; ?>
</span>
<?php endif; ?>
<?php if ($params->get('show_introtext')) : ?>
<p class="mod-articles-category-introtext">
<?php echo $item->displayIntrotext; ?>
</p>
<?php endif; ?>
<?php if ($params->get('show_readmore')) : ?>
<p class="mod-articles-category-readmore button button-reverse">
<?php if ($item->params->get('access-view') == false) : ?>
<?php echo JText::_('MOD_ARTICLES_CATEGORY_REGISTER_TO_READ_MORE'); ?>
<?php elseif ($readmore = $item->alternative_readmore) : ?>
<?php echo $readmore; ?>
<?php echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit')); ?>
<?php elseif ($params->get('show_readmore_title', 0) == 0) : ?>
<?php echo JText::sprintf('Nu bekijken'); ?>
<?php else : ?>
<?php echo JText::_('MOD_ARTICLES_CATEGORY_READ_MORE'); ?>
<?php echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit')); ?>
<?php endif; ?>
</p>
<?php endif; ?>
</a>
</div>
</div>
<?php endforeach; ?>
</div>
-
- Joomla! Apprentice
- Posts: 19
- Joined: Wed Mar 09, 2016 12:00 pm
Re: Exclude current article in Article categories module
answer was found in the helper.php, so instead of an override i turned the whole bunch in a custom module. There is already an $exclude in place (used to exclude specific items), solved it by adding the active item to that array
- pe7er
- Joomla! Master
- Posts: 24974
- Joined: Thu Aug 18, 2005 8:55 pm
- Location: Nijmegen, Netherlands
- Contact:
Re: Exclude current article in Article categories module
You can use filters to exclude an article id.
I've added the following to exclude the current article from the "Articles - Newsflash" module:
In modules/mod_articles_news/helper.php
Note: this example is a core hack that might be overwritten with a Joomla update...
I've added the following to exclude the current article from the "Articles - Newsflash" module:
In modules/mod_articles_news/helper.php
Code: Select all
// Do not display the current article in the module output
$model->setState('filter.article_id', $app->input->get('id'));
$model->setState('filter.article_id.include', false);
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com