I’m currently sorting pages from two differents subfolder (Projects and News). I would like to be able to sort them manually to render them into the frontpage.
So my actual code is :
<?php foreach($pages->children()->visible()->sortBy('modified', 'asc')->flip() as $product): ?>
<php endforeach ?>
I know it is not the right way to do it because this code takes in account the modified pages.
For example, I would like to get the third « News » page comes to first position, and the second page from projects comes to the last…This could be possible if I grouped my « projects » and « news » pages into one single folder, but I would like to avoid that, and to know if an other way was possible.
I don’t really understand your requirement. Manually for me means, that you have a select field or whatever, where you select the pages you want to display and there order. Then. you renders these manually selected pages in the. page.
What is the underlying pattern for “3rd news page” and then “second page from projects comes last”?
Right, this is only an example, the user would like to change this order as he wants to. In the homepage, the teaser could change the order between “projects” and “news” pages.
What do you mean by “pattern” ?
Well, you want to display pages from two different subfolders manually. But you want to do your manual sorting with code. But with code, you can only do things that have some inherent logic, a pattern, like always take two form the first list, then continue with 1 from the next list, then again two from the first list etc. The opposite would be to do something randomly with code.
But if you want to do something manually, you can’t do it with a programming algorithm. Why don’t you use a plugin like Kirby relationship where the users can select and order the pages they want to show on the start page?
Ok, I tried this plugin, but it didn’t really suited me because the plugin is working with a selecting principle, and I don’t need this. I am more interested by this plugin : https://github.com/lukaskleinschmidt/kirby-sortable because it allows to directly change the order of the subpages. But now, I realize that we can’t make multiple parents, it only find the siblings or the selected subpages from one level.
So, my new idea is to add a date field to every “news” and “projects” subpages. This way I could create a collection and order them arbitrary from this date value (which is not far from what I am looking for). Do you have some advices about doing that ?
EDIT : this way, I could get what I was looking for :