When managing a Joomla website, you might encounter a situation that seems like a bug but is actually a deliberate feature: unpublished articles appearing on the front-end of your site. If you are logged in as an administrator or a manager, Joomla allows you to view content that is not yet live. While this is incredibly useful for reviewing content before it goes public, it can lead to significant confusion for clients or junior editors who might think a draft has accidentally been published.
In this guide, we will explore why this happens, how Joomla's Access Control List (ACL) governs this behavior, and the various methods you can use to hide these articles or make their 'unpublished' status more obvious to your team.
Understanding the Joomla Front-End Preview Feature
By default, Joomla is designed to facilitate a collaborative workflow. Imagine a scenario where a content creator writes a blog post and sets it to 'Unpublished'. They then send the URL to a manager for approval. Because the manager has the necessary permissions, they can click that link and see the article exactly as it will appear once live, without ever needing to navigate the complexities of the Joomla back-end.
This feature saves time and provides a 'What You See Is What You Get' (WYSIWYG) experience for decision-makers. However, if your template does not clearly label these articles as 'Unpublished', an admin browsing the front-end might see a list of articles and assume they are all visible to the general public. This is where the confusion typically begins.
Method 1: Managing Permissions via ACL
Before diving into code, it is vital to understand that this 'issue' is strictly tied to user permissions. A guest visitor or a standard 'Registered' user will never see an unpublished article. This visibility is reserved for user groups with 'Edit State' or 'Configure' permissions for the content component.
If you want to prevent certain users from seeing unpublished articles, you should review their User Group assignments. If a client is assigned to the 'Administrator' or 'Super User' group, they will see everything.
To restrict this: 1. Navigate to Users > Groups. 2. Create a custom group with limited permissions. 3. Ensure they do not have the Edit State permission in the Global Configuration for the Content component.
By keeping your clients in a user group that lacks 'Edit State' rights, they will only see what the public sees, effectively solving the confusion without any technical modifications.
Method 2: Using Template Overrides to Hide Content
If you must remain logged in as a Super User but want to hide unpublished articles from the front-end view entirely, the most robust way to do this is through a Template Override. This allows you to intercept the article rendering process and check its status before it is displayed.
To create an override for a single article view, follow these steps:
- Go to Extensions > Templates > Templates.
- Click on your active template details and files.
- Click the Create Overrides tab.
- Select
com_contentand thenarticle. - Navigate to the
html/com_content/article/directory in your template files and opendefault.php.
Inside this file, you can add a logic check at the very top to see if the article is unpublished (state 0). Here is an example of how you might redirect a user or show a message:
// Get the article state
$articleState = $this->item->state;
// Check if the article is unpublished (0)
if ($articleState == 0) {
// Option A: Redirect to the homepage
$app = JFactory::getApplication();
$app->enqueueMessage('This article is not yet available for public viewing.', 'notice');
$app->redirect(JUri::root());
exit;
}
By implementing this, even an administrator clicking a direct link to an unpublished article will be redirected, ensuring that the front-end 'live' environment remains strictly for published content.
Method 3: Modifying Content Models (Advanced Only)
For those who want to change this behavior globally across category blogs, featured views, and single articles, you would technically need to modify the underlying models. These files include:
models/article.phpmodels/articles.phpmodels/featured.php
Warning: Modifying core Joomla files is highly discouraged. Any changes made to these files will be overwritten the next time you update Joomla. If you choose this path, you would need to adjust the SQL queries within these models that check for user permissions and article states. We strongly recommend sticking to Method 1 or Method 2 to maintain a maintainable and secure website.
Adding Visual Cues to Your Template
If the primary goal is simply to reduce confusion, you might not need to hide the articles at all. Instead, you can add a visual 'Unpublished' badge. Many modern Joomla templates do this automatically by checking the $item->state and adding a CSS class to the article wrapper.
In your override file, you could add something like this:
<div class="item-page <?php echo ($this->item->state == 0) ? 'is-unpublished' : ''; ?>">
<?php if ($this->item->state == 0) : ?>
<div class="alert alert-warning">Note: This article is UNPUBLISHED and visible only to you.</div>
<?php endif; ?>
<!-- Article content goes here -->
</div>
Then, in your CSS file, you can style the .is-unpublished class with a semi-transparent background or a red border to make it immediately obvious that the content is in a draft state.
Frequently Asked Questions
Can I disable this feature for specific categories only?
Yes. By using a Template Override as described in Method 2, you can wrap your logic in an if statement that checks the category ID: if ($this->item->catid == 12 && $this->item->state == 0). This allows you to have some categories that allow previews and others that remain strictly hidden.
Why does Joomla show unpublished articles to managers by default?
It is designed for editorial workflows. In professional publishing environments, a content manager needs to verify the layout, image alignment, and formatting on the actual front-end template before hitting the 'Publish' button. This prevents layout breaks on the live site.
Does this affect SEO or search engines?
No. Search engine crawlers act as guest visitors. Since they are not logged in as administrators, they cannot see or index unpublished articles. Your SEO rankings are safe, and there is no risk of 'duplicate content' or 'draft leakage' to Google.
Wrapping Up
Joomla's ability to show unpublished content to administrators is a powerful tool for quality control, but it requires a clear understanding of the ACL system to prevent confusion. If your clients are confused by seeing unpublished posts, the best approach is to either adjust their User Group permissions or implement a simple Template Override to add a clear 'Draft' watermark or notification.
By taking these steps, you ensure a smoother experience for your clients while maintaining the professional editorial capabilities that Joomla is known for.