EnglishIs there a way within a theme to change the sort order options? I found where to change them in the core code, however I'm trying to avoid making any changes there so I don't have issues when I upgrade in the future.
I'd like to make my own sort order options such as:
Oldest First
Newest First
and remove sort by rating (I plan to remove ratings), etc.
I'll keep looking into it tonight, but any advice is appreciated.
Offline
Don't make changes to the core. If you do and Piwigo is updated, all of your changes will be overwritten. That said....
You can change sort order by category.
Admin > Albums > Manage >
Go to the album/category you want to change. To edit this album, click on the little tools. If it's a sub-album, click on the little folder. At the top of that page, you should see the name of the album you're working on. There will be a little orange ball with an arrow, the next will be four green circles on top of one another, with an arrow pointing down. Click on that. You can set up the sort order there.
Or use the edit function in the album, that will take you to the edit page.
Or you can use the localfiles editor and edit local/config/config.inc.php. Refer to the misc section of the link at the top right of the textarea ("Display reference file: "config_default.inc.php") for sort order.
Offline
lisaviolet, thanks! Again you've been a huge help. I messed with the album editor quite a bit. However I never noticed the per album sort options. That helped me out a lot as I do want different sort orders for certain albums.
I'm also aware of not making edits to CORE as it'll cause issues with an upgrade and/or I'll lose those changes.
Is there any way to change the actual sort options that show up in the dropdown when viewing the album? The defaults are:
Default
Average rate
Most visited
Creation date
Post date
File name
Rank
Permissions
I'd like to simplify the list and customize it to only have these options:
Default
Oldest First (<== Creation date ascending)
Newest First (<== Creation date descending)
Last edited by bjordan (2011-04-29 18:05:10)
Offline
I don't think you can do that without messing with the core, but one of the developers would better know the answer to that question.
Offline
you could do your changes in a plugin. here is what the core does:
return trigger_event('get_category_preferred_image_orders',
array(
array(l10n('Default'), '', true),
array(l10n('Average rate'), 'average_rate DESC', $conf['rate']),
array(l10n('Most visited'), 'hit DESC', true),
array(l10n('Creation date'), 'date_creation DESC', true),
array(l10n('Post date'), 'date_available DESC', true),
array(l10n('File name'), 'file ASC', true),
array(
l10n('Rank'),
'rank ASC',
('categories' == @$page['section'] and !isset($page['flat']) and !isset($page['chronology_field']) )
),
array( l10n('Permissions'), 'level DESC', is_admin() )
));your plugin event handler function that will receive the default array and you could return yours... I advise you to leave the Default. This is a special case where some albums could have different sort orders. Also in the default mode, the quick search results will be sorted automatically by relevance...
Offline
rvelices wrote:
you could do your changes in a plugin. here is what the core does:
I found that code in CORE but wanted to avoid making changes to CORE so I was looking for an alternative way. I'll look into making a plugin to handle this. I really appreciate you pointing me in the right direction.
Offline
In a personal plugin, insert this code:
add_event_handler('get_category_preferred_image_orders', 'personal_category_preferred_image_orders');
function personal_category_preferred_image_orders($order)
{
return array(
array(l10n('Default'), '', true),
array(l10n('Oldest First'), 'date_creation ASC', true),
array(l10n('Newest First'), 'date_creation DESC', true),
);
}Offline
P@t, thanks for the response. With your code and the plugin documentation I was able to get this up and going in about 5 minutes.
I really appreciate the all the help everyone has given me. I'm impressed with the fast and helpful responses I've been getting related to this project. I'm definitely quickly becoming more and more of a Piwigo fan.
You guys really seem to have a nice event handler structure in place that makes implementing things pretty straight forward. As a fellow developer I really appreciate that.
Offline
bjordan wrote:
I'm definitely quickly becoming more and more of a Piwigo fan.
:-)
Can you pass topic to resolved - link in the first post ;-)
Offline
I'm cross posting this here as well in case anyone runs across this thread and is trying to do the same thing. I submitted the plugin to the Extensions repository that solves this.
[extension by bjordan] Simple Sort Orders
Last edited by bjordan (2011-07-01 23:58:31)
Offline