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]
  • Digg
  • del.icio.us
  • Technorati
  • StumbleUpon
  • Facebook
  • MySpace
  • Google
  • Live
  • YahooMyWeb
  • Yahoo! Buzz
  • NewsVine
  • Ma.gnolia
  • Print this article!
  • E-mail this story to a friend!
  • TwitThis
  • Share/Save/Bookmark

Tags: , , , , ,

Reader's Comments

  1. |

    Liam, I am glad that you are among people who goes for “Joomla!” :mrgreen: .-= Hicham´s last blog ..Justice and Stereotype =-My ComLuv Profile

  2. |

    I hosted my new site from powweb, and did a little work on it, then I downloaded joomla and I am navagating through joomla trying to find how to upload my material from powweb? I tried to get into powweb website maker and it doesn’t work… obviously because I downloaded joomla. Now, I also can’t access joomla from powweb, I have to go to the joomla website. If someone could help me out that would be great because i’m very confused!!!!!! This is my first time ever making a site so… speak english
    .-= search engine marketing tips´s last blog ..Web directory submissions- get high pace outputs =-My ComLuv Profile

  3. |

    Thank you for this post :D I successfully changed the sorting order of my weblinks to alphabetical

  4. |

    You’re welcome; surprisingly easy, isn’t it? Glad it was helpful ;-)

Leave a Comment

CommentLuv Enabled
:-) :D :cry: ;-) :cool: :neutral: :mad: :!: :razz: :roll: :???: :arrow: :lol: :sad: :?: :oops: :eek: :idea: :mrgreen: :shock: :twisted: :skull :evil: :buzz :coffee