Default sort order for articles backend - revisited

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
raddersred
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Wed Jul 13, 2011 5:02 pm

Default sort order for articles backend - revisited

Post by raddersred » Mon Jan 21, 2019 2:39 pm

I know this has been asked before but I haven't found a definitive and recent answer, so here goes.

Is it possible to change the default article sort order in the BACKEND to list articles by descending date modified?

Apologies if I have missed an existing thread where this has been answered, or even worse, if this feature has been built into Joomla and I haven't found it ;)

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13655
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Default sort order for articles backend - revisited

Post by toivo » Mon Jan 21, 2019 5:15 pm

If you would like to change the default sort order of the articles listing permanently, you can do that by overriding the articles view of the com_content component at the back end.
Toivo Talikka, Global Moderator

raddersred
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Wed Jul 13, 2011 5:02 pm

Re: Default sort order for articles backend - revisited

Post by raddersred » Tue Jan 22, 2019 7:44 am

Thanks Toivo. Excuse my Ignorance but what does that mean please? I am not a programmer and don't normally dabble with Joomla code so what would I have to do?

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 10690
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Default sort order for articles backend - revisited

Post by sozzled » Tue Jan 22, 2019 7:58 am

raddersred wrote:
Tue Jan 22, 2019 7:44 am
I am not a programmer and don't normally dabble with Joomla code so what would I have to do?
I don't want this to sound silly but, if you don't know how to write PHP code, don't try to do this yourself. Unless you are good with writing PHP then it's probably not a good idea to dabble without having a good safety-belt and harness system in place. In other words, don't do this on your live production site until you've figured out how to do it safely.

Alternatively, you could probably have this job done in half-an-hour or less ... if you spent a few dollars and paid a professional web developer (who knows what they're doing) to do the job for you.

Basically, as @toivo says, you need to look at the PHP source code for the articles view in the folder ../administrator/components/com_content and then make the change as you want to make it. Knowledge of PHP is essential. Then you need to create an override. Knowledge of creating an override is essential. The step-by-step instructions will probably take longer for you to read and process than if you explain what you want to a professional programmer.
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?” :)

raddersred
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Wed Jul 13, 2011 5:02 pm

Re: Default sort order for articles backend - revisited

Post by raddersred » Tue Jan 22, 2019 8:04 am

Not a problem. I have programmed but not in PHP. So I understand your warning :)

In that case I'll leave it alone. I thought it might just be a case of simply tweaking a couple of lines of code.

Hopefully at some point in the future it will become an option built into the admin backend either to change the order in options, or maybe Joomla should remember the last sort order used, at next login.

Thanks.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13655
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Default sort order for articles backend - revisited

Post by toivo » Tue Jan 22, 2019 8:20 am

In fact, the change involves only a couple of lines of code, as shown below.

Create a template override so that the modified code is safe from the next Joomla update. Do not modify the core code.

The first tutorial has all the theory behind template overrides, and the second tutorial shows how to create an override using the Template Manager. The override file will be written into the html folder of the back end template, where it can be modified.

https://docs.joomla.org/How_to_override ... omla!_core

https://docs.joomla.org/J3.x:How_to_use ... _Overrides

In this case, following the second tutorial, the file administrator/components/com_content/views/articles/default.php is copied to administrator/templates/isis/html/com_content/articles/default.php. You can then modify that file in the editor in the Editor tab of Templates: Customise (Isis)

Code: Select all

/*
if (strpos($listOrder, 'publish_up') !== false)
{
	$orderingColumn = 'publish_up';
}
elseif (strpos($listOrder, 'publish_down') !== false)
{
	$orderingColumn = 'publish_down';
}
elseif (strpos($listOrder, 'modified') !== false)
{
	$orderingColumn = 'modified';
}
else
{
	$orderingColumn = 'created';
}
*/
$orderingColumn         = 'modified';
$saveOrder		= true;
$listDirn		= 'descending';
The old code is commented out using /* and */, just to show which lines have been replaced. The last three lines do the heavy lifting in customising the default sort order.
Toivo Talikka, Global Moderator

raddersred
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Wed Jul 13, 2011 5:02 pm

Re: Default sort order for articles backend - revisited

Post by raddersred » Tue Jan 22, 2019 12:13 pm

Great! Thanks Toivo. Very helpful. I'll have a go at that in the next day or so.

raddersred
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Wed Jul 13, 2011 5:02 pm

Re: Default sort order for articles backend - revisited

Post by raddersred » Tue Jan 22, 2019 1:09 pm

Hmm. I just tried to do this and it still sorts by Author. I think I have made the override correctly (see enclosed) but it seems to ignore it.
sortorder.png
You do not have the required permissions to view the files attached to this post.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13655
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Default sort order for articles backend - revisited

Post by toivo » Tue Jan 22, 2019 1:31 pm

That sounds odd. Have you saved & closed the file after editing it?
Toivo Talikka, Global Moderator

raddersred
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Wed Jul 13, 2011 5:02 pm

Re: Default sort order for articles backend - revisited

Post by raddersred » Tue Jan 22, 2019 1:42 pm

Thanks for your time on this. Yes all saved. It has permissions of 644. Is that correct?
sortorder2.png
You do not have the required permissions to view the files attached to this post.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 13655
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Default sort order for articles backend - revisited

Post by toivo » Tue Jan 22, 2019 1:53 pm

The permissions 644 are all right. Clear the cache, just in case, log out and log back in. Template overrides work all right, also in the back end.
Toivo Talikka, Global Moderator

raddersred
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Wed Jul 13, 2011 5:02 pm

Re: Default sort order for articles backend - revisited

Post by raddersred » Tue Jan 22, 2019 2:01 pm

It seems to revert to sort by ID descending if I logout and back in.

If I jump around between other menu items and return, it remembers the last sort order I manually selected.

I've tried clearing all cache but I'll try using another browser, clear the browser cache (not sure if that is relevant) and clear Joomla cache and report back.

Thanks

raddersred
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Wed Jul 13, 2011 5:02 pm

Re: Default sort order for articles backend - revisited

Post by raddersred » Tue Jan 22, 2019 2:36 pm

That made no difference. Don't worry. I don't want to take up too much of your time.


Locked

Return to “Administration Joomla! 3.x”