0

I'm using Tagger from devdemon and I wonder if it is possible to ordeby a customfield. It seems to me that the entries are orderby entry_date and I can't find a way to change it.

0

According to the documentation, there isn't one. However, looking at the add-on code, it appears you can either order by entry_title, entry_date, or random.

However, it would be quite easy for you to go into the logic and add another case statement to the existing switch/case statement. Look for this line:

switch ($this->EE->TMPL->fetch_param('orderby'))

in this file:

/system/expressionengine/third_party/tagger/mod.tagger.php

Then just add another case statement or modify the add-on to take any value:

    switch ($this->EE->TMPL->fetch_param('orderby'))
    {
        case 'entry_title':
            $this->EE->db->order_by('ct.title', $sort);
            break;
        case 'random':
            $this->EE->db->order_by('RAND()', FALSE);
            break;
        default:
            $this->EE->db->order_by('ct.entry_date', $sort);
            break;
    }

For instance, you could modify the default statement to accept any value; just know it will error if you provide a bad value (since this directly modifies the MySQL statement):

        default:
            $orderby = $this->EE->TMPL->fetch_param('orderby');
            $this->EE->db->order_by($orderby, $sort);
            break;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.