Problem: We want to be able to sort simple query tables based on the order that blocks appear on a page, but query tables currently only sort ascending/descending based on one of the columns returned by your search.
(There’s actually a second problem here, which is that performing a simple query on a page will only return the top level blocks in a table, unless child blocks meet some additional query criteria)
Solution: In order to sort a query table based on the order that blocks appear on a page, we need a column to sort by, with the relevant information. Suggestion:
- Generate hierarchical data for each block item.
- Expose this hierarchical data as an option in the Simple Query Builder.
Example Page Content:
1 Parent Block
1.1 Child
1.2 Child
1.2.1 Child of Child
2 Another Parent Block
Example Query:
{{query (and ([[Some Page]] blockorder )}}
Example Query Table:
| block order ^ | Block |
| 1.0 | Parent Block |
| 1.1 | Child |
| 1.2 | Child |
| 1.2.1 | Child of Child |
| 2.0 | Another Parent Block |