-
-
Notifications
You must be signed in to change notification settings - Fork 44
[6.1] Add the possibility to show unpublished articles in mod_articles #3683
Copy link
Copy link
Closed
Description
New language relevant PR in upstream repo: joomla/joomla-cms#45990 Here are the upstream changes:
Click to expand the diff!
diff --git a/language/en-GB/mod_articles.ini b/language/en-GB/mod_articles.ini
index e6c897d5791d0..c5c6db003969a 100644
--- a/language/en-GB/mod_articles.ini
+++ b/language/en-GB/mod_articles.ini
@@ -70,6 +70,7 @@ MOD_ARTICLES_FIELD_TITLE_HEADING_NONE="None"
MOD_ARTICLES_FIELD_TITLE_LABEL="Article Title"
MOD_ARTICLES_FIELD_TRIGGER_EVENTS_DESC="Enable this option to trigger three plugin events (afterDisplayTitle, beforeDisplayContent, afterDisplayContent) for each article in the results list."
MOD_ARTICLES_FIELD_TRIGGER_EVENTS_LABEL="Trigger Plugin Events"
+MOD_ARTICLES_FIELD_UNPUBLISHED_LABEL="Show Unpublished Articles"
MOD_ARTICLES_INFO="Details"
MOD_ARTICLES_OPTION_ASCENDING_VALUE="Ascending"
MOD_ARTICLES_OPTION_CREATED_VALUE="Created Date"
diff --git a/modules/mod_articles/mod_articles.xml b/modules/mod_articles/mod_articles.xml
index 0db2d925f7b05..1253b382198f0 100644
--- a/modules/mod_articles/mod_articles.xml
+++ b/modules/mod_articles/mod_articles.xml
@@ -501,6 +501,19 @@
<option value="hide">MOD_ARTICLES_OPTION_ONLYARCHIVEDHIDE_VALUE</option>
</field>
+ <field
+ name="show_unpublished"
+ type="radio"
+ label="MOD_ARTICLES_FIELD_UNPUBLISHED_LABEL"
+ layout="joomla.form.field.radio.switcher"
+ default="0"
+ filter="integer"
+ showon="show_archived!:show"
+ >
+ <option value="0">JNO</option>
+ <option value="1">JYES</option>
+ </field>
+
<field
name="filteringspacer2"
type="spacer"
diff --git a/modules/mod_articles/src/Helper/ArticlesHelper.php b/modules/mod_articles/src/Helper/ArticlesHelper.php
index 0b0027bab82c3..8c0e7914a1d83 100644
--- a/modules/mod_articles/src/Helper/ArticlesHelper.php
+++ b/modules/mod_articles/src/Helper/ArticlesHelper.php
@@ -212,6 +212,11 @@ public function getArticles(Registry $params, SiteApplication $app)
$articles->setState('filter.published', ContentComponent::CONDITION_ARCHIVED);
}
+ // Filter unpublished articles
+ if ($params->get('show_unpublished', 0) === 1 && (($user->authorise('core.edit.state', 'com_content') && $user->authorise('core.edit', 'com_content')) || ($user->authorise('core.edit.state', 'com_content') && $user->authorise('core.edit.own', 'com_content')))) {
+ $articles->setState('filter.published', [ContentComponent::CONDITION_UNPUBLISHED, ContentComponent::CONDITION_PUBLISHED]);
+ }
+
// Check if we include or exclude articles and process data
$ex_or_include_articles = $params->get('ex_or_include_articles', 0);
$filterInclude = true;
diff --git a/modules/mod_articles/tmpl/default_items.php b/modules/mod_articles/tmpl/default_items.php
index ecac94fc31df0..fcc81639b0a57 100644
--- a/modules/mod_articles/tmpl/default_items.php
+++ b/modules/mod_articles/tmpl/default_items.php
@@ -10,6 +10,7 @@
defined('_JEXEC') or die;
+use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
@@ -18,11 +19,14 @@
$gridCols = 'grid-cols-' . $params->get('layout_columns');
}
+$currentDate = Factory::getDate()->format('Y-m-d H:i:s');
+
?>
<ul class="mod-articles-items<?php echo ($params->get('articles_layout') == 1 ? ' mod-articles-grid ' . $gridCols : ''); ?> mod-list">
<?php foreach ($items as $item) : ?>
<?php
$displayInfo = $item->displayHits || $item->displayAuthorName || $item->displayCategoryTitle || $item->displayDate;
+ $canEdit = $item->params->get('access-edit');
?>
<li>
<article class="mod-articles-item" itemscope itemtype="https://schema.org/Article">
@@ -44,6 +48,18 @@
</<?php echo $item_heading; ?>>
<?php endif; ?>
+ <?php if ($item->state === 0) : ?>
+ <span class="badge bg-warning"><?php echo Text::_('JUNPUBLISHED'); ?></span>
+ <?php endif; ?>
+
+ <?php if ($item->publish_up > $currentDate) : ?>
+ <span class="badge bg-warning"><?php echo Text::_('JNOTPUBLISHEDYET'); ?></span>
+ <?php endif; ?>
+
+ <?php if ($item->publish_down !== null && $item->publish_down < $currentDate) : ?>
+ <span class="badge bg-warning"><?php echo Text::_('JEXPIRED'); ?></span>
+ <?php endif; ?>
+
<?php echo $item->event->afterDisplayTitle; ?>
<?php if ($displayInfo) : ?>
diff --git a/modules/mod_articles/tmpl/default_titles.php b/modules/mod_articles/tmpl/default_titles.php
index 0f3f443058c9b..dcabe184abe01 100644
--- a/modules/mod_articles/tmpl/default_titles.php
+++ b/modules/mod_articles/tmpl/default_titles.php
@@ -10,6 +10,11 @@
defined('_JEXEC') or die;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
+
+$currentDate = Factory::getDate()->format('Y-m-d H:i:s');
+
?>
<ul class="mod-articles mod-list">
<?php foreach ($items as $item) : ?>
@@ -19,6 +24,18 @@
<?php echo $item->title; ?>
</span>
</a>
+
+ <?php if ($item->state == 0) : ?>
+ <span class="badge bg-warning"><?php echo Text::_('JUNPUBLISHED'); ?></span>
+ <?php endif; ?>
+
+ <?php if ($item->publish_up > $currentDate) : ?>
+ <span class="badge bg-warning"><?php echo Text::_('JNOTPUBLISHEDYET'); ?></span>
+ <?php endif; ?>
+
+ <?php if ($item->publish_down !== null && $item->publish_down < $currentDate) : ?>
+ <span class="badge bg-warning"><?php echo Text::_('JEXPIRED'); ?></span>
+ <?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
Reactions are currently unavailable