- Title: Senior Contributor
- Status: Offline
- From: Netherlands
- Registered: 2008-11-16
- Posts: 378
Topic: How to sort categories client-side?
I like to sort the categories in the template file (and not in the backend). Is there anyone who knows how to do that?
(I don't want to change the order of the categories in the database, but want to have them sorted alphabetical 'client-side').
- Title: rawkstar wannabe
- Status: Offline
- Registered: 2009-01-16
- Posts: 362
Re: How to sort categories client-side?
hi, why not just create a separate function that orders the category by name instead of the specified category_order?
you can add this function on your /_includes/functions.php
Code:
function get_categories_order_name()
{
global $db;
$categories = array();
$sql = 'SELECT *
FROM categories
ORDER BY `name` ASC';
$result = $db->query($sql);
while ($row = $result->fetch_assoc())
{
$categories[] = array('id' => $row['id'], 'name' => $row['name'], 'var_name' => $row['var_name'], 'title' => $row['title'], 'description' => $row['description'], 'keywords' => $row['keywords']);
}
return $categories;
}
and use this to extract the categories ordered alphabetically.
will host your job board for you at minimal cost! read more:
http://mim.io/acb992
- Title: Senior Contributor
- Status: Offline
- From: Netherlands
- Registered: 2008-11-16
- Posts: 378
Re: How to sort categories client-side?
I'll try to get it to work. Thanks!
Posts [ 3 ]
Guest posting is disabled. You must login or register to post a reply.