Change default published state to unpublished

General questions relating to Joomla! 1.5 There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Locked
imjustmike
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Wed Nov 11, 2009 1:35 pm

Change default published state to unpublished

Post by imjustmike » Thu Nov 12, 2009 1:53 pm

I'm trying to change the default article state for new articles from published to unpublished. I've tracked down the code that generates the radio icons in administrator\components\com_content\admin.content.html.php

The code is

Code: Select all

echo $lists['state'];
What I want to know is where the function is being called from, and how I can change the default from published to unpublished, I checked in the same file, but couldn't find a reference to any radio inputs.

NB: my knowledge of php isn't, well, good.

User avatar
lekankou
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Jan 20, 2011 4:11 pm

Re: Change default published state to unpublished

Post by lekankou » Thu Jan 20, 2011 4:31 pm

Hello !
I had the same problem this afternoon and i was looking for an answer.
I spent a little time to find it but ... none over the net!
Since I've found how to change the default state published to unpublished of a new article, I think it should be helpfull for someone else.

Open the file \components\com_content\views\article\view.html.php
and look for these lines :

Code: Select all

// Radio Buttons: Should the article be published
		$lists['state'] = JHTML::_('select.booleanlist', 'state', '', $article->state);


and change it to:

Code: Select all

// Radio Buttons: Should the article be published
		// lekankou's add for UNpublished by default :
		if($article->id) {
			$query = 'SELECT state FROM #__content WHERE id = '. (int) $article->id;
			$db->setQuery($query);
			$article->state = $db->loadResult();
		} else {
			$article->state = 0;
		}
		// End of lekankou's add 
$lists['state'] = JHTML::_('select.booleanlist', 'state', '', $article->state);
and that's enough !

;)

LeKankou (a french guy)
LeKankou
(a friendly french guy)

tujthevux
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Apr 30, 2012 8:04 am
Location: Hanoi -Vietnam
Contact:

Re: Change default published state to unpublished

Post by tujthevux » Wed May 02, 2012 3:00 am

Open the file \components\com_content\views\article\view.html.php
and look for these lines :

Code: Select all

// Radio Buttons: Should the article be published
		$lists['state'] = JHTML::_('select.booleanlist', 'state', '', $article->state);


and change it to:

Code: Select all

// Radio Buttons: Should the article be published
		// lekankou's add for UNpublished by default :
		if($article->id) {
			$query = 'SELECT state FROM #__content WHERE id = '. (int) $article->id;
			$db->setQuery($query);
			$article->state = $db->loadResult();
		} else {
			$article->state = 0;
		}
		// End of lekankou's add 
$lists['state'] = JHTML::_('select.booleanlist', 'state', '', $article->state);
Why I don't find the code in Joomla 2.5.

User avatar
lekankou
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Jan 20, 2011 4:11 pm

Re: Change default published state to unpublished

Post by lekankou » Wed Oct 09, 2013 9:33 am

Hello I've found this elsewhere and it seems to work :
What you could do is to edit the file article.xml that is located in the directory \administrator\components\com_content\models\forms and change the default value of the default from "1" to "0".
Code:
...
...
<field name="state" type="list" label="JSTATUS"
description="JFIELD_PUBLISHED_DESC" class="inputbox"
filter="intval" size="1" default="1"
>
<option value="1">
JPUBLISHED</option>
<option value="0">
JUNPUBLISHED</option>
<option value="2">
JARCHIVED</option>
<option value="-2">
JTRASHED</option>
</field>
...
...

Be informed that you are changing a core Joomla! file. So, make a copy of the original file. Also, be aware that this file may get overwritten by future releases/versions of Joomla!
May you try this ? ;)
LeKankou
(a friendly french guy)

cwdee
Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Fri Oct 12, 2012 5:45 am

Re: Change default published state to unpublished

Post by cwdee » Mon Mar 09, 2015 9:27 am

In Joomla 3.4.0, setting the default published state in administrator/components/com_content/models/forms/article.xml doesn't seem to have any effect for new articles. I can see that article.xml is being processed to display the form because if I change the order of options, or add an extra option, that does take effect. However, the default option is not selected.
If I 'Add new article' in the back-end and look on #_content, a mostly empty row has already been created for the new id, and this already has state set to 1. Where is this blank article being created? Is it possible that that code is not honouring the default state in article.xml?


Locked

Return to “General Questions/New to Joomla! 1.5”