The title might be a bit vague, but I’ll try to explain it as good as possible…
I’m busy with a site that has a portfolio. Instead of ordering the entries based on the entry_date, title, or whatever I want to sort them by entry_id, but put a different entry on top everyday.
I made a php-function that does just this, but I’m having troubles implementing it in EE.
Here’s the function:
function order_by_interval($array) {
$returnArray = array();
$length = count($array);
$i = (time() / 60 / 60 / 24) % $length;
for($j=0;$j < $length;$j++) {
if($i > $length - 1) { $i = 0; }
$returnArray[$j] = $array[$i];
$i++;
}
return $returnArray;
}
$entries = array(23, 34, 54, 62, 71, 77);
$sorted = order_by_interval($entries);
$string = implode('|', $sorted);
I would then be able to use $string in the new fixed_order parameter for exp:weblog:entries.
The only problem I’ve run into is that I need the entry id’s before I parse the php and I need to use the outcome of that function to sort the entries accordingly. (See my dilemma?)
Hardcoding the fixed_order parameter isn’t really an option since the portfolio is updated regularly.
So I figured I need to whip up an extension that reorders the results before they get sent to the client, but I have no idea which hook I need to grab. I looked over the weblog_entries_tagdata-hook, but rewriting that much code and functionality isn’t my idea of a simple extension… is there another hook that let’s me manipulate the resultset before EE starts returning the data?
Greets, Wizz
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.