It took a few google searches until I could find out how to change the default weblinks order. A lot of websites showed how to do this via the admin back-end panel in the advanced configuration... I can't see this panel, there is no advanced parameters under a weblinks category.
The issue is that suppose a menuitem links to a category of weblinks, the default sort order (as in the first time you view the page) is the order in the admin panel (not even by most recent). I'm going to show you how to do this by title in ascending order without installing any 3rd-party extension as well as by any of the database values used by each link.
Joomla 1.5.x
I found the page to edit after going through the Joomla forums for a bit. Their solution only permanently sets the default sort order to WEBLINK TITLE in order from A to Z. The below code with my modifications maintains the functionality for the user to change the sort order by clicking on the column titles.
The page you want is /components/com_weblinks/models/category.php and you are going to edit the _buildQuery() function, search the file for the following comment and text. As always, I would recommend you make a copy of the file before making the change just in case you need to revert the change:
// We need to get a list of all weblinks in the given category $query = 'SELECT *' . ' FROM #__weblinks' . ' WHERE catid = '. (int) $this->_id. ' AND published = 1' . ' AND archived = 0'; $query.=($filter_order!="ordering")?' ORDER BY '. $filter_order .' '. $filter_order_dir .', ordering':' ORDER BY title ASC';
- // We need to get a list of all weblinks in the given category
- $query = 'SELECT *' .
- ' FROM #__weblinks' .
- ' WHERE catid = '. (int) $this->_id.
- ' AND published = 1' .
- ' AND archived = 0';
- $query.=($filter_order!="ordering")?' ORDER BY '. $filter_order .' '. $filter_order_dir .', ordering':' ORDER BY title ASC';
To sort by another value on page load
To do this, change the word 'title' in the above code to one of the following values:
- id => sort by ID
catid => sort by Category ID
sid => ? dunno
title => by web link title
alias => sort by alias title
url => sort by url
description => sort by description
date => sort by date added (most recent or oldest first)
hits => sort by hits (number of times clicked on)
published => obviously by whether they're published or not... no idea why u would
checked_out => sort by checked out (will either display or not on the front page so again not any use to sort by this)
checked_out_time => just cos this value exists, don't know why you would order by this
ordering => the setting it's on if you haven't made this modification. I don't like it and nor do u if you've been trawling the web for this solution.
archived => is or not
approved => again
params => what params? I couldn't find any
A little more
to change A-Z or Z-A change ASC (ascending) to DESC (descending) in the last bit of the above code.
To sort by 2 categories, change ' ORDER BY title ASC' to 'ORDER BY title ASC, hits DESC' where 'title' is the first and 'hits' in descending (so most hit first)
For specific categories
For my website, I've shoved all my links into one page because I didn't like how weblink categories display on the weblinks page. I could modify the page for categories (by default it's an ugly unordered list), but changing scripts gets overwritten in a joomla upgrade so too many changes is a hard process to keep track of.
Joomla 1.6.x
Responding to a comment by J16 User (9 July 2011): As an update for those of us brave enough to use the upgraded CMS, I have looked into this and it would appear that Joomla! CMS have not changed this. I'd imagine it quite low priority.
This is easier to tweak in the upgrade. The following will again maintain the functionality for your website visitors to change the order. If you want to change the default order of your weblinks in the front-end of your Joomla! website, you will need to modify the following file:
/components/com_weblinks/models/category.php (make a backup/copy first)
Line 181: $orderCol = JRequest::getCmd('filter_order', 'ordering');
- Line 181: $orderCol = JRequest::getCmd('filter_order', 'ordering');
$orderCol = JRequest::getCmd('filter_order', 'title');
- $orderCol = JRequest::getCmd('filter_order', 'title');
- id - by weblink identifying number
- catid - by category identifying number
- title - by weblink title
- alias - by its alias - same as weblink title only without crazy symbols
- url - could be an issue if some of your links have http and some don't
- description - not recommended!
- date - the one I use for most recent
- created - this is also a date formatted field
- modified - and this is a date formatted field
- hits - number of times that weblink has been visited
- state - this is the J16 published/unpublished status
- ordering
- featured
$listOrder = JRequest::getCmd('filter_order_Dir', 'ASC');
- $listOrder = JRequest::getCmd('filter_order_Dir', 'ASC');