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
  • Twitter
  • StumbleUpon
  • Facebook
  • del.icio.us
  • Technorati
  • MySpace
  • Google Bookmarks
  • Live
  • Yahoo! Buzz
  • Posterous
  • Reddit
  • Propeller
  • blogmarks
  • Blogplay
  • Ping.fm
  • RSS
  • Print
  • Add to favorites
  • PDF
  • email

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 =-.

  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 =-.

  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 ;-)

  5. |

    Great tip! I spent some time searching for a mod or plugin to did this, and all those were pretty much overkill. Then, I stumbled upon your page. Just utilized it for a pretty large Link list on betterworldstrategies.com (in production).

    Thanks so much,

    Gene

  6. |

    I spent a long time myself searching for a solution so I thought I’d share it. I’m very glad the article was helpful!

  7. |

    Nice post! you did it good. I look forward to future post.
    I’m new in Joomla system. I’m used wordpess but my hobby is learn Joomla and drupal.
    Thanks a lot for sharing,

    Reference:
    german language schools

  8. |

    Nice post, but I wish there was an easier way. What happens at the next upgrade?

  9. |

    It’s a shame Joomla hasn’t built options like this into the admin back end. Why would anyone want their oldest links to be displayed first? Oversights like this force users to to find fixes such as the one I posted which can be quite a headache. If an upgrade means I have to re do all my work arounds, I may consider not upgrading or maybe using another CMS!

  10. |

    Thanks alot for this post.
    Really helpful!

  11. |

    I own a blog and due to some personal reasons, I would like to be inaccessible to anyone for the time being. I used Blogger. I have changed the weblink and made the blog invisible to public.

  12. |

    yes, i found it.. thanks my friend

Leave a Comment

:D :-) :( :o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: