The Joomla! Forum ™



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.



Post new topic Reply to topic  [ 20 posts ] 
Author Message
PostPosted: Sat Apr 02, 2011 1:48 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed May 09, 2007 3:44 pm
Posts: 152
How can I change the default sort order in the Article Manager in the Backend? Currently it sorts all articles alphabetically, but I would like to have the default sort order by Date showing the most recent article first.

_________________
Brian D. Saylor
IT Admin / Webmaster
Mountville Fire Company No. 1
http://www.mountvillefire.com


Top
 Profile  
 
PostPosted: Mon Apr 04, 2011 4:23 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed May 09, 2007 3:44 pm
Posts: 152
Anyone with a suggestion? I'm not even sure which file to look into to try to figure it out.

_________________
Brian D. Saylor
IT Admin / Webmaster
Mountville Fire Company No. 1
http://www.mountvillefire.com


Top
 Profile  
 
PostPosted: Wed Apr 06, 2011 9:02 pm 
Joomla! Intern
Joomla! Intern

Joined: Sun Oct 23, 2005 6:40 am
Posts: 66
Go to Article Manager - Options. Click on the Blog/Featured Layouts tab. You'll see the ordering options there.


Top
 Profile  
 
PostPosted: Wed Apr 06, 2011 11:29 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed May 09, 2007 3:44 pm
Posts: 152
Your answer sorts the way the articles are shown in the front end. I am looking to change the way the articles are displayed by default in the backend. Right now when you open the article manager from the admin control panel, they are ordered alphabetically, I would like it to sort by date descending by default, showing the most recently created first.

I am pretty sure I will have to do some core file editing to accomplish this, but I am unsure where to begin looking for the file that controls this.

_________________
Brian D. Saylor
IT Admin / Webmaster
Mountville Fire Company No. 1
http://www.mountvillefire.com


Top
 Profile  
 
PostPosted: Sat Apr 09, 2011 9:51 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Mar 22, 2011 5:48 pm
Posts: 33
Probie715, check this thread out: viewtopic.php?p=2281600

_________________
Birou Notar Public in sector 4, Bucuresti, zona Tineretului-Sincai. Servicii: autentificare contract, divort, legalizare acte, procura, succesiune: http://notariat-tineretului.net


Top
 Profile  
 
PostPosted: Sat Apr 09, 2011 12:14 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed May 09, 2007 3:44 pm
Posts: 152
That explains where to make the changes in J1.5.x, I checked the specified file in J1.6.x and the closest I can find is:
Code:
// no direct access
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.tooltip');
JHTML::_('script','system/multiselect.js',false,true);

$user      = JFactory::getUser();
$userId      = $user->get('id');
$listOrder   = $this->escape($this->state->get('list.ordering'));
$listDirn   = $this->escape($this->state->get('list.direction'));
$saveOrder   = $listOrder == 'a.ordering';
?>


Where do I find where the variables "list.ordering" and "list.direction" are declared?

_________________
Brian D. Saylor
IT Admin / Webmaster
Mountville Fire Company No. 1
http://www.mountvillefire.com


Top
 Profile  
 
PostPosted: Mon Jun 27, 2011 4:16 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri May 06, 2011 4:46 pm
Posts: 4
Any answer to this topic? I have the same desire for this.


Top
 Profile  
 
PostPosted: Sun Jul 03, 2011 8:27 pm 
Joomla! Intern
Joomla! Intern

Joined: Thu May 19, 2011 11:12 am
Posts: 92
Location: The Netherlands
You have to change the file: /administrator/components/com_content/models/articles.php.
At line 94 (in 1.6.4) you'll find the following line:
Code:
      parent::populateState('a.title', 'asc');

To sort on date descending you should change this to:
Code:
      parent::populateState('a.created', 'desc');


Changing this file means of course means the update is probably gone after a Joomla update. It could probably be fixed with a simple plugin. Maybe i'll put one together some time...


Top
 Profile  
 
PostPosted: Wed Jul 06, 2011 1:51 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Fri May 06, 2011 4:46 pm
Posts: 4
Thanks! That worked like a charm. It's crazy to me that this isn't a native option.


Top
 Profile  
 
PostPosted: Wed Jul 06, 2011 4:45 pm 
Joomla! Intern
Joomla! Intern

Joined: Thu May 19, 2011 11:12 am
Posts: 92
Location: The Netherlands
Glad it was helpful.
I just want to mention that the given line of code sorts on creation-date. you can of course change this to sort on for example modification-date (a.modified)...

I found out after my last post that it's not (yet) possible in Joomla 1.6.4 to fix this using a plugin, as lists don't trigger events. So, unfortunately no plugin..


Top
 Profile  
 
PostPosted: Thu Jul 14, 2011 11:35 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Nov 13, 2009 2:09 pm
Posts: 33
This was fantastic info to find when you have a massive and growing amount of articles!

It really should be an option to set a default sorting - its an admin gold-tool:)

_________________
------
Ubuntu server-admin and site-builder/manager
Custom Webhosting


Top
 Profile  
 
PostPosted: Thu Jul 21, 2011 6:39 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat May 21, 2011 1:32 am
Posts: 17
Thank you for this info, I've been scratching my head trying to sort out the articles.php file.
One other thing, do you know how you'd set it so by default it filters out a specific category?
The YVComments plugin saves comments as their own article (in the category "comments"). So naturally, the comments show up alongside the content articles in the article manager. Can you think of a way to modify it so that by default, it does not show the "Comments" category?

Edit: Solved - At least for now. It seems a little hack-y, but since YVComment leaves the "language" as "undefined", I changed

Code:
   $language = $this->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
      $this->setState('filter.language', $language);


to
Code:
   $language = $this->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
      $this->setState('filter.language', '*');


So by default, it filters by "all" (defined) languages, dropping the undefined ones.

It probably breaks the language search function, but since my site is monolingual (is that even a word?), it doesn't really matter.

Does that seem right to anyone else?


Top
 Profile  
 
PostPosted: Sun Jul 24, 2011 11:46 am 
Joomla! Intern
Joomla! Intern

Joined: Thu May 19, 2011 11:12 am
Posts: 92
Location: The Netherlands
I think it could indeed be confusing to save comments as articles. In my opinion it is also not right conceptually..

The author of YVComment says on this page:
Quote:
Comments may be stored in the same database table used by content (where they are treated as a special type of Article), or in their own table.


Seems to me you should try using the latter, to keep articles and comments separated..

Hope this helps.

Regards,
Ruud


Last edited by thx_nb on Tue Jul 26, 2011 12:20 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Jul 25, 2011 7:00 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat May 21, 2011 1:32 am
Posts: 17
I agree with you, however, the main draw for me to yvcomment (besides being free), is that it allows for comments-on-comments. However, this function only works if the comments are saved as articles in the jos_content table -- the functionality breaks if the comments are stored in their own table.


Top
 Profile  
 
PostPosted: Tue Jul 26, 2011 12:49 pm 
Joomla! Intern
Joomla! Intern

Joined: Thu May 19, 2011 11:12 am
Posts: 92
Location: The Netherlands
You could change the query in the articles model file.
Of course this is a really hacky solution, because every joomla core update will destroy your changes. To apply this solution you have to add the following code to the "getListQuery" method in /administrator/components/com_content/models/articles.php:
Code:
$query->where('a.catid <> 15');

Put it around line 186 and replace the number 15 with the ID of the category you want to exclude.

Another option would be to override the articles default view and filter skip the comment records by checking the category. The problem with this solution is, that the number of records displayed in de articles list will be lower. For example, if the record count per page is set to 20 and 12 of them are comments, then you'll have only 8 records on that page. You could of course set the records count to a higher value, but I think this value is not saved inbetween sessions.
To apply this solution copy /administrator/components/com_content/views/articles/default.php to /administrator/templates/<<yourSelectedTemplate>>/html/com_content/articles/default.php.

Then, change the code right after the start of the foreach loop at line 114 (or so):
Code:
      <?php foreach ($this->items as $i => $item) :
becomes
Code:
      <?php foreach ($this->items as $i => $item) :
         if($item->catid <> 15):

Also, change line 190 (or so):
Code:
         <?php endforeach; ?>
becomes
Code:
         <?php endif;
         endforeach; ?>

Of course, again you'll need to change the number 15 to the ID of the category you want to skip...

The former solution prevents overhead on your query, while the latter keeps working with a new version of Joomla.

Hope this helps.

Regards,
Ruud Kobes


Top
 Profile  
 
PostPosted: Tue Jul 26, 2011 7:49 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed May 09, 2007 3:44 pm
Posts: 152
Thanks for hijacking the thread

_________________
Brian D. Saylor
IT Admin / Webmaster
Mountville Fire Company No. 1
http://www.mountvillefire.com


Top
 Profile  
 
PostPosted: Wed Jul 27, 2011 2:01 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat May 21, 2011 1:32 am
Posts: 17
@thx_nb - Thanks for the great info. I'll try it out.

Probie715 wrote:
Thanks for hijacking the thread

Any time.


Top
 Profile  
 
PostPosted: Fri Oct 28, 2011 11:18 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Jun 06, 2009 6:52 am
Posts: 34
Can you tell me if this same method will work for changing the default ordering of modules and plugins? What page would I find this code?

_________________
"It doesn't matter where we come from, what we've done or suffered, or even if we make a difference. We live as though the world was what it should be, to show it what it can be."
~ Angel, Season 4, Episode 67, "Deep Down"


Top
 Profile  
 
PostPosted: Sat Dec 03, 2011 4:27 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Apr 19, 2010 1:13 pm
Posts: 29
thx_nb

thank you...


Top
 Profile  
 
PostPosted: Mon Jan 16, 2012 9:45 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Dec 04, 2011 10:30 am
Posts: 3
thx_nb

thanks works good


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ] 



Who is online

Users browsing this forum: No registered users and 47 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group