3

Good chance this is more of a feature request than a question you can help out. But as I am new to Craft plugin development and might oversee something I ask it anyways:

Now that it is possible to customize the index pages in the CP using the plugin hooks modifyEntryTableAttributes and getEntryTableAttributeHtml, what do I have to do to make my custom columns appear in the sort order dropdown / make the entries sortable by my new columns?

0
2

You weren’t overlooking anything, we were :)

We just released Craft 2.3.2616 with four new hooks:

That should do the trick for you.

7
  • Yes, that's great! Thanks Brandon. Would it be greedy if I asked for those hooks to also support a source parameter? I also wondered how to define a secondary sort key for each attribute, is this possible?
    – carlcs
    Dec 4 '14 at 9:10
  • @carlcs The source is not known when element types' defineSortableAttributes() is called; it's only called once, on the initial page load, and the options don't change when changing sources. (The only exception to that is, the JS will add the "Structure" option in dynamically when a structured source is selected.) Not sure what you mean by a "secondary source key for each attribute"? Dec 4 '14 at 10:45
  • I meant a secondary key that you can sort by, if the primary values were the same (e.g. sort by lightswitch field and then by datetime field).
    – carlcs
    Dec 4 '14 at 10:54
  • Thanks so far, but I hope you find a working solution to define sortableAttributes per source. I think this is essential to the whole functionality (I don't want the Client to be able to sort the "Blog" structure by "Opening Time" for example).
    – carlcs
    Dec 4 '14 at 11:01
  • 1
    @carlcs The keys you add will be passed directly into the order parameter, so you can juts throw a comma in the array key. Dec 4 '14 at 12:43

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.