So last question I gotten it all to work nicely. Now just missing if possible, sorting.
Is it a easy Kirby native way to sortBy() the category using the final text? Also worth saying, the sort option works well, but I want sort on the final translated text value witch is stored in the config file sa an array.
May I ask for your input on this as well @texnixe?
Not sure if you follow me? Let me know if you need anything else of info?
It’s a bit late now , if you want, you can send me the relevant parts of your project as zip or upload to GitHub, then I could look into this tomorrow.
I am presented with a new issue, regarding the sort order. I wish to control the order, but after adding the links for filtering each category I am faced with another issue. So how can I add sort order as a extra field in the config file? (Not sure how to add that to the array).
Also how will you go around getting it sorted right in the front-end? I am thinking that the easy way around this is to use numbers just, 01, 02, 03 etc.
So you don’t want to sort by alphabetical order of the “translated” strings (Some title 1, Some title 2) anymore but the order these values have in within the array?
If you use numbers for your options like this:
options:
1: Option 1
2: Option 2
you can, of course, use these to sort by and no need to sort by a custom page model/method.
I move away from the alphabetical sorting to a number based sorting. Here is my config file with the “translated” array. Now is there a way to attach another value to the each to give them the sorting order? Like'sort' => 05 ?
The idea here is to group with a certain sort order of the categories, not filter. The original idea was to sort alphabetically based on the values of the c::set() array.
Thank you @texnixe! Of course in a perfect world I will have named urls. Cause this is also the param('1') in the url. So that is why I was thinking of this as a separate value. But thank you!
Worth mentioning is that if ever want to reorder this you also need to resave all the pages with the new value since this is also reflected in my category select dropdown in the panel.
That is it would be great in a future version to add that.
Oh, I see. Then maybe this quick and dirty solution is not so ideal, after all, and a multi-dimensional array with a sort order attached to it would be the more future-proof solution.
Then you would need this wonderful page method/model again, with the difference that you now have to deal with a multi-dimension array to grab the correct sorting value…
See above, I tend to have afterthoughts and then edit my answers to provide more detailed information.
And then I guess you want an adapted method as well… But to enhance the learning effect, try it yourself first… and you will be proud of yourself if you get it to work .