Skip to content

Commit b95a479

Browse files
author
Phil E. Taylor
authored
[4] Introducing Joomla’s first blank state (#33264)
1 parent 9bffff6 commit b95a479

File tree

8 files changed

+92
-1
lines changed

8 files changed

+92
-1
lines changed

administrator/components/com_content/src/View/Articles/HtmlView.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ public function display($tpl = null)
8888
$this->activeFilters = $this->get('ActiveFilters');
8989
$this->vote = PluginHelper::isEnabled('content', 'vote');
9090

91+
if (!count($this->items) && $this->get('IsBlankSlate'))
92+
{
93+
$this->setLayout('blankstate');
94+
}
95+
9196
if (ComponentHelper::getParams('com_content')->get('workflow_enabled'))
9297
{
9398
PluginHelper::importPlugin('workflow');

administrator/components/com_content/src/View/Featured/HtmlView.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ public function display($tpl = null)
8888
$this->activeFilters = $this->get('ActiveFilters');
8989
$this->vote = PluginHelper::isEnabled('content', 'vote');
9090

91+
if (!count($this->items) && $this->get('IsBlankSlate'))
92+
{
93+
$this->setLayout('blankstate');
94+
}
95+
9196
if (ComponentHelper::getParams('com_content')->get('workflow_enabled'))
9297
{
9398
PluginHelper::importPlugin('workflow');
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* @package Joomla.Administrator
4+
* @subpackage com_content
5+
*
6+
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
7+
* @license GNU General Public License version 2 or later; see LICENSE.txt
8+
*/
9+
10+
defined('_JEXEC') or die;
11+
12+
use Joomla\CMS\Language\Text;
13+
use Joomla\CMS\Router\Route;
14+
15+
?>
16+
<form action="<?php echo Route::_('index.php?option=com_content&view=articles'); ?>" method="post" name="adminForm" id="adminForm">
17+
18+
<div class="px-4 py-5 my-5 text-center">
19+
<span class="fa-8x icon-copy mb-4 article" aria-hidden="true"></span>
20+
<h1 class="display-5 fw-bold"><?php echo Text::_('COM_CONTENT_BLANKSTATE_TITLE'); ?></h1>
21+
<div class="col-lg-6 mx-auto">
22+
<p class="lead mb-4">
23+
<?php echo Text::_('COM_CONTENT_BLANKSTATE_CONTENT'); ?>
24+
</p>
25+
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
26+
<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>
27+
<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>
28+
</div>
29+
</div>
30+
</div>
31+
32+
<input type="hidden" name="task" value="">
33+
<input type="hidden" name="boxchecked" value="0">
34+
</form>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* @package Joomla.Administrator
4+
* @subpackage com_content
5+
*
6+
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
7+
* @license GNU General Public License version 2 or later; see LICENSE.txt
8+
*/
9+
10+
defined('_JEXEC') or die;
11+
12+
require __DIR__ . '/../articles/blankstate.php';

administrator/language/en-GB/com_content.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ COM_CONTENT_ATTRIBS_ARTICLE_SETTINGS_LABEL="Options"
1212
COM_CONTENT_ATTRIBS_FIELDSET_LABEL="Options"
1313
COM_CONTENT_BATCH_OPTIONS="Batch process the selected articles"
1414
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."
15+
COM_CONTENT_BLANKSTATE_BUTTON_ADD="Add your first article"
16+
COM_CONTENT_BLANKSTATE_BUTTON_LEARNMORE="Learn more"
17+
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."
18+
COM_CONTENT_BLANKSTATE_TITLE="No Articles have been created yet."
1519
COM_CONTENT_CHANGE_STAGE="Change stage"
1620
COM_CONTENT_CHANGE_STAGE_AMBIGUOUS_TRANSITIONS="Some transitions are ambiguous for this condition. Please select your preferred transition and proceed."
1721
COM_CONTENT_CONFIG_ARTICLE_SETTINGS_DESC="These settings apply for article layouts unless they are changed for a specific menu item or article."

libraries/src/MVC/Model/ListModel.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,29 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu
149149
}
150150
}
151151

152+
/**
153+
* Is this a blank state, I.e: no items of this type regardless of the searched for states.
154+
*
155+
* @return boolean
156+
*
157+
* @since __DEPLOY_VERSION__
158+
*/
159+
public function getisBlankSlate()
160+
{
161+
$sql = $this->query
162+
->clear('select')
163+
->clear('values')
164+
->clear('bounded')
165+
->clear('limit')
166+
->clear('order')
167+
->clear('where')
168+
->select('count(*)');
169+
170+
$this->_db->setQuery($sql);
171+
172+
return !($this->_db->loadResult() > 0);
173+
}
174+
152175
/**
153176
* Method to cache the last query constructed.
154177
*

tests/Codeception/_support/Page/Acceptance/Administrator/AdminPage.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ class AdminPage extends AcceptanceTester
2828
*/
2929
public static $systemMessageContainer = ['id' => 'system-message-container'];
3030

31+
/**
32+
* The form element with id "adminForm"
33+
*
34+
* @var array
35+
* @since __DEPLOY_VERSION__
36+
*/
37+
public static $adminForm = ['id' => 'adminForm'];
38+
3139
/**
3240
* The element id which contains page title in administrator header.
3341
*

tests/Codeception/acceptance/administrator/components/com_content/ContentListCest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function loadsWithoutPhpNoticesAndWarnings(AcceptanceTester $I)
4646
{
4747
$I->wantToTest('that it loads without php notices and warnings.');
4848
$I->amOnPage(ContentListPage::$url);
49-
$I->waitForElement(ContentListPage::$filterSearch);
49+
$I->waitForElement(ContentListPage::$adminForm);
5050
$I->checkForPhpNoticesOrWarnings();
5151
}
5252

0 commit comments

Comments
 (0)