We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My category table
The listing is as follows:
But I wish to be like this: Sort by name:
Root
How can I do?
The text was updated successfully, but these errors were encountered:
you would have to recalculate rgt and lft for this. Load the tree from the DB, sort the records using PHP and save them back.
Sorry, something went wrong.
how i have to recalculate rgt and lft for this? ..or I can create a new column 'parent_id'?
Please check if I did right:
public function orderByName(){ $parent=Category::model()->findByPk(1); $descendants=$parent->children()->findAll(array("order" => "name DESC")); self::childrenOrderByName($descendants,$parent); } private function childrenOrderByName($descendants, $parent){ foreach ($descendants as $key => $category) { $category->moveAsFirst($parent); $_parent = Category::model()->findByPk($category->id); $_descendants=$_parent->children()->findAll(array("order" => "name DESC")); if(count($_descendants) > 0){ self::childrenOrderByName($_descendants,$_parent); } } }
No branches or pull requests
My category table
The listing is as follows:
But I wish to be like this:
Sort by name:
Root
How can I do?
The text was updated successfully, but these errors were encountered: