Skip to content

[4] Introducing Joomla’s first blank state #1690

@jgerman-bot

Description

@jgerman-bot

New language relevant PR in upstream repo: joomla/joomla-cms#33264 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_content/src/View/Articles/HtmlView.php b/administrator/components/com_content/src/View/Articles/HtmlView.php
index eda91831e62a..5ebfd55b6410 100644
--- a/administrator/components/com_content/src/View/Articles/HtmlView.php
+++ b/administrator/components/com_content/src/View/Articles/HtmlView.php
@@ -88,6 +88,11 @@ public function display($tpl = null)
 		$this->activeFilters = $this->get('ActiveFilters');
 		$this->vote          = PluginHelper::isEnabled('content', 'vote');
 
+		if (!count($this->items) && $this->get('IsBlankSlate'))
+		{
+			$this->setLayout('blankstate');
+		}
+
 		if (ComponentHelper::getParams('com_content')->get('workflow_enabled'))
 		{
 			PluginHelper::importPlugin('workflow');
diff --git a/administrator/components/com_content/src/View/Featured/HtmlView.php b/administrator/components/com_content/src/View/Featured/HtmlView.php
index fa8735cc8312..7b5bc7726c46 100644
--- a/administrator/components/com_content/src/View/Featured/HtmlView.php
+++ b/administrator/components/com_content/src/View/Featured/HtmlView.php
@@ -88,6 +88,11 @@ public function display($tpl = null)
 		$this->activeFilters = $this->get('ActiveFilters');
 		$this->vote          = PluginHelper::isEnabled('content', 'vote');
 
+		if (!count($this->items) && $this->get('IsBlankSlate'))
+		{
+			$this->setLayout('blankstate');
+		}
+
 		if (ComponentHelper::getParams('com_content')->get('workflow_enabled'))
 		{
 			PluginHelper::importPlugin('workflow');
diff --git a/administrator/components/com_content/tmpl/articles/blankstate.php b/administrator/components/com_content/tmpl/articles/blankstate.php
new file mode 100644
index 000000000000..8a7d56081b1b
--- /dev/null
+++ b/administrator/components/com_content/tmpl/articles/blankstate.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @package     Joomla.Administrator
+ * @subpackage  com_content
+ *
+ * @copyright   (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
+ * @license     GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\Router\Route;
+
+?>
+<form action="<?php echo Route::_('index.php?option=com_content&view=articles'); ?>" method="post" name="adminForm" id="adminForm">
+
+	<div class="px-4 py-5 my-5 text-center">
+		<span class="fa-8x icon-copy mb-4 article" aria-hidden="true"></span>
+		<h1 class="display-5 fw-bold"><?php echo Text::_('COM_CONTENT_BLANKSTATE_TITLE'); ?></h1>
+		<div class="col-lg-6 mx-auto">
+			<p class="lead mb-4">
+				<?php echo Text::_('COM_CONTENT_BLANKSTATE_CONTENT'); ?>
+			</p>
+			<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
+				<a href="<?php echo Route::_('index.php?option=com_content&view=article&layout=edit'); ?>" class="btn btn-primary btn-lg px-4 me-sm-3"><?php echo Text::_('COM_CONTENT_BLANKSTATE_BUTTON_ADD'); ?></a>
+				<a href="https://docs.joomla.org/Special:MyLanguage/Adding_a_new_article" class="btn btn-outline-secondary btn-lg px-4"><?php echo Text::_('COM_CONTENT_BLANKSTATE_BUTTON_LEARNMORE'); ?></a>
+			</div>
+		</div>
+	</div>
+
+	<input type="hidden" name="task" value="">
+	<input type="hidden" name="boxchecked" value="0">
+</form>
diff --git a/administrator/components/com_content/tmpl/featured/blankstate.php b/administrator/components/com_content/tmpl/featured/blankstate.php
new file mode 100644
index 000000000000..e6fbad1ecb02
--- /dev/null
+++ b/administrator/components/com_content/tmpl/featured/blankstate.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * @package     Joomla.Administrator
+ * @subpackage  com_content
+ *
+ * @copyright   (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
+ * @license     GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+require __DIR__ . '/../articles/blankstate.php';
diff --git a/administrator/language/en-GB/com_content.ini b/administrator/language/en-GB/com_content.ini
index 61b9ef0c8939..e1c95b905357 100644
--- a/administrator/language/en-GB/com_content.ini
+++ b/administrator/language/en-GB/com_content.ini
@@ -12,6 +12,10 @@ COM_CONTENT_ATTRIBS_ARTICLE_SETTINGS_LABEL="Options"
 COM_CONTENT_ATTRIBS_FIELDSET_LABEL="Options"
 COM_CONTENT_BATCH_OPTIONS="Batch process the selected articles"
 COM_CONTENT_BATCH_TIP="If a category is selected for move/copy, any actions selected will be applied to the copied or moved articles. Otherwise, all actions are applied to the selected articles."
+COM_CONTENT_BLANKSTATE_BUTTON_ADD="Add your first article"
+COM_CONTENT_BLANKSTATE_BUTTON_LEARNMORE="Learn more"
+COM_CONTENT_BLANKSTATE_CONTENT="Articles are the main content on most Joomla sites. You can use the Joomla Article Editor to create and manage your content."
+COM_CONTENT_BLANKSTATE_TITLE="No Articles have been created yet."
 COM_CONTENT_CHANGE_STAGE="Change stage"
 COM_CONTENT_CHANGE_STAGE_AMBIGUOUS_TRANSITIONS="Some transitions are ambiguous for this condition. Please select your preferred transition and proceed."
 COM_CONTENT_CONFIG_ARTICLE_SETTINGS_DESC="These settings apply for article layouts unless they are changed for a specific menu item or article."
diff --git a/libraries/src/MVC/Model/ListModel.php b/libraries/src/MVC/Model/ListModel.php
index 1d7e64ecfec8..cb411d54ff90 100644
--- a/libraries/src/MVC/Model/ListModel.php
+++ b/libraries/src/MVC/Model/ListModel.php
@@ -149,6 +149,29 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu
 		}
 	}
 
+	/**
+	 * Is this a blank state, I.e: no items of this type regardless of the searched for states.
+	 *
+	 * @return boolean
+	 *
+	 * @since __DEPLOY_VERSION__
+	 */
+	public function getisBlankSlate()
+	{
+		$sql = $this->query
+			->clear('select')
+			->clear('values')
+			->clear('bounded')
+			->clear('limit')
+			->clear('order')
+			->clear('where')
+			->select('count(*)');
+
+		$this->_db->setQuery($sql);
+
+		return !($this->_db->loadResult() > 0);
+	}
+
 	/**
 	 * Method to cache the last query constructed.
 	 *
diff --git a/tests/Codeception/_support/Page/Acceptance/Administrator/AdminPage.php b/tests/Codeception/_support/Page/Acceptance/Administrator/AdminPage.php
index 7708b8cd431e..e3dfe3d60040 100644
--- a/tests/Codeception/_support/Page/Acceptance/Administrator/AdminPage.php
+++ b/tests/Codeception/_support/Page/Acceptance/Administrator/AdminPage.php
@@ -28,6 +28,14 @@ class AdminPage extends AcceptanceTester
 	 */
 	public static $systemMessageContainer = ['id' => 'system-message-container'];
 
+	/**
+	 * The form element with id "adminForm"
+	 *
+	 * @var    array
+	 * @since  __DEPLOY_VERSION__
+	 */
+	public static $adminForm = ['id' => 'adminForm'];
+
 	/**
 	 * The element id which contains page title in administrator header.
 	 *
diff --git a/tests/Codeception/acceptance/administrator/components/com_content/ContentListCest.php b/tests/Codeception/acceptance/administrator/components/com_content/ContentListCest.php
index fb197c0b4a48..41b0d1f5b0f8 100644
--- a/tests/Codeception/acceptance/administrator/components/com_content/ContentListCest.php
+++ b/tests/Codeception/acceptance/administrator/components/com_content/ContentListCest.php
@@ -46,7 +46,7 @@ public function loadsWithoutPhpNoticesAndWarnings(AcceptanceTester $I)
 	{
 		$I->wantToTest('that it loads without php notices and warnings.');
 		$I->amOnPage(ContentListPage::$url);
-		$I->waitForElement(ContentListPage::$filterSearch);
+		$I->waitForElement(ContentListPage::$adminForm);
 		$I->checkForPhpNoticesOrWarnings();
 	}
 

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions