E107: forum - sorting doesn't work

Created on 20 Jun 2018  路  13Comments  路  Source: e107inc/e107

Latest github version, php 7.0.29

  • because forum table is displayed as tree, I am not sure how ordering should work (at first parent, then subforums inside parent, then subsubforums inside subforum or all forums are even)

But ordering by ID doesn't work any way (when click on forum ID):

image

Admin-UI bug

All 13 comments

@Jimmi08 Ordering worked quite well on my install.
Maybe you should do it in the following order:

  1. Drag and drop the main forums in the order you like it with the sort button on the right.
  2. Reload the page and the will move the subforums of the main forums in the right place.
  3. Now re-order the subforums to your liking.
  4. Reload the page to update the list

What you can NOT do by reordering:

  • you can not move a parent forum as child forum to another parent forum.
  • you can not move a child forum from on parent to another parent forum
  • you can not move a sub forum of a child forum to the parent forum
    This can only be done by editing the forum parent and subforum settings directly.

That worked for me.

@SimSync I don't want to change order of forums (on Frontend). I want to use sorting by ID (when you click on ID label in admin_ui). Sorry for confusing.

That will not work as as much understand the tree model, because the relationship between parent and child element has to stay intact.
Maybe @deltik can tell you more about it.

@SimSync I understand, but then there should be option - if it's this case - to remove sorting option from column titles. I think that book/chapters have the same problem.

Personally, to work with data in tree display (you know what I mean) is for me harder that in normal view with selecting parents etc. But I am able to get what I need by custom plugin.

@Jimmi08: The sort by ID or by anything else actually does work, but the tree takes priority in the sort so that the tree is not broken.

The behavior before #3025 was to apply the sorting strictly as requested but still display depths, which led to a confusing layout where parents and children were all jumbled.

It is programatically not too difficult to switch from tree view to flat list view. Since #3209, tree view is disabled if you perform a search query. All that's done in the e_admin_controller_ui is $this->getTreeModel()->setParam('sort_parent', null); when a search query is present.

Perhaps it'd make sense to add a toggle for tree view or flat list view when a tree view is possible. I'd like to know what @SimSync thinks.

@Deltik Don't spend time on this (I mean that toggle), I can live without it, others are not complaining. There are important issues.

@Deltik A toggle would be nice in some situations, but i think more important is to be able to filter the tree properly and that all data is displayed (when not filtered).

Just my five cents, theoretically out of the box (please don't "kill" me, i've not scavenged throught the code or sql): Wouldn't it be faster to make all that sort at db level, with a single query, inside MySql??? :confused:

@rica-carv: Yes, it would be faster to build a tree and sort it using a MySQL query, and that's how it was done before (a fake tree constructed with MySQL functions), but @CaMer0n asked me to make a pure PHP tree implementation in order to avoid adding a dependency on MySQL CREATE ROUTINE privileges. Tree models were totally broken for e107 webmasters who did not have that privilege.

Again, out of the box, but can't that also be ancheived with MySQl without CREATE ROUTINE ?
Like this?

@rica-carv: The suggestions in that Stack Overflow Q&A don't cover e107's use case. The top answer won't make the results look like a tree and has an additional limitation of requiring the parent ID to be lower than the row's ID. Furthermore, in mid-2018, most web hosts don't provide a new enough version of MySQL/MariaDB to support WITH RECURSIVE, which would cause even more compatibility problems.

Until there's a better solution, I think we can get away with a pure PHP tree implementation for now. Most trees are not very big, so the performance impact is negligible. Bigger tables are very unlikely to be trees, like the user table, so they are detected and rendered as flat lists, which perform better.

@Jimmi08 Can this issue be closed? Sorting works, but is respecting the tree integrity which may not produce the result you're expecting. But that's not a bug ...

Yes, I thought it was solved already. Sorry

Was this page helpful?
0 / 5 - 0 ratings