Skip to content
New issue

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

[Users] Make items in Account Panel sortable #3993

Open
robbrandt opened this issue Nov 27, 2019 · 1 comment
Open

[Users] Make items in Account Panel sortable #3993

robbrandt opened this issue Nov 27, 2019 · 1 comment
Labels
Milestone

Comments

@robbrandt
Copy link

Q A
Zikula Version 3.x.x
PHP Version x.x.x

Summary

Currently, items displayed in /user/account seem to be displayed in the order they are encountered in the file system. This could result in "the most important" icon buried in the middle of there are a lot of them. It would be great if we could designed the order in which module's links are displayed.

Desired Behavior

Allow an administrator to arrange the order in which modules show their links.

Possible Solution

A "weight" or "sort" field when editing an extension? extensions/module/modify/12

Context

Allows administrators to get the right icon in front of a user.

@Guite Guite added this to the Future Ideas milestone Nov 28, 2019
@Kaik
Copy link
Contributor

Kaik commented Dec 3, 2019

@robbrandt I have played with this long time ago and the problem is that some modules have more than one link... and then "define most important"... Here is the way I solved it:
before links array is passed to view I added usort based on additional order property https://github.com/zikula/core/blob/master/src/system/UsersModule/Controller/AccountController.php#L55

        usort($accountLinks, function ($item1, $item2) {
            if ($item1['order'] == $item2['order']) {
                return 0;
            }
            return $item1['order'] < $item2['order'] ? -1 : 1;
        });

and then each link in each LinkContainer is with additional that order property

        $links[] = [
            'url'   => $this->router->generate('zikulausersmodule_access_logout'),
            'text' => $this->translator->__('Log out'),
            'icon'  => 'power-off text-danger',
            'order'  => 100
        ];

This solution is bad because order is hardcoded but... there is no other easy way to do it, unless you want to add new functionality - admin page that will allow admin to order all links the way he needs and then store that somewhere and use it to order links array before passing to view...
...somewhere there was an issue/idea to move links from link container to menu module or something like that... maybe this way those links could be more configurable than now

@Guite Guite modified the milestones: Future Ideas, 3.1.0 Feb 7, 2020
@Guite Guite changed the title Make items in Account Panel sortable [Users] Make items in Account Panel sortable Jul 15, 2020
@craigh craigh modified the milestones: 3.1.0, 3.2.0 Dec 28, 2020
@Guite Guite modified the milestones: 3.2.0, 4.0.0 Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants