A Slice of Life
msgbartop

commentary on issues in politics, culture, environment and technology
msgbarbottom

08 Nov 09 How To Change Weblink Sort Order in Joomla

Joomla!
Image via Wikipedia

I’ve been adding new links to the weblinks section of my Joomla installation (Sliced Wikizine)for some time now and have managed to build quite a nice collection of very cool Web 2.0 type links in a range of categories (including: Animation Blogging Code Graphics Web Design Social Media Multimedia Writing and Online Tools )

One thing that always bothered me was that the new links I added always displayed last on the list of links.  Of course, links can be manually reordered using the admin backend but I couldn’t help thinking there had to be an easier way.

Of course there is…

To change the sort order of weblinks, you need to edit one file in your Joomla installation.  Go to: yoursite/joomla_folder/components/com_weblinks/models/category.php

Edit the file ‘category.php’  (It’s a good idea to download a backup copy of the file first, just in case…).  Use notepad or another text editor to edit the file.  Code editor in cpanel works just fine.

Between lines 224 and 231 you’ll find this statement:

$query = ‘SELECT *’ .
‘ FROM #__weblinks’ .
‘ WHERE catid = ‘. (int) $this->_id.
‘ AND published = 1′ .
‘ AND archived = 0′.
‘ ORDER BY ‘. $filter_order .’ ‘. $filter_order_dir .’, ordering’;
return $query;

Make this change on line 229:

$query = ‘SELECT *’ .
‘ FROM #__weblinks’ .
‘ WHERE catid = ‘. (int) $this->_id.
‘ AND published = 1′ .
‘ AND archived = 0′.
//’ ORDER BY ‘. $filter_order .’ ‘. $filter_order_dir .’, ordering’;
‘ ORDER BY date DESC’;
return $query;

What we have done is commented out the line //’ ORDER BY ‘. $filter_order .’ ‘. $filter_order_dir .’, ordering’; to make it inactive.  All links will now be sorted by date in descending order (most recent first).

Other sort options can be created by using these fields: url, title, description, date, hits.

For example, you could sort all weblinks alphabetically by title by changing the statement which now appears on line 230 to:

‘ ORDER BY title ASC’;

Reblog this post [with Zemanta]

Tags: , , , , , , , , , , , ,