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

Ordering of terms in the 'Taxonomies' tab when editing Resources #23

Open
PeteVox opened this issue Apr 29, 2015 · 0 comments
Open

Ordering of terms in the 'Taxonomies' tab when editing Resources #23

PeteVox opened this issue Apr 29, 2015 · 0 comments
Assignees

Comments

@PeteVox
Copy link

PeteVox commented Apr 29, 2015

Hi there.

We'd noticed that terms weren't ordered by 'menuindex' or 'a-z' in the main 'Taxonomies' tab when editing resources. We updated our local install in order to use 'menuindex'...perhaps worth including option to order by various fields in a later release?

Great component. Many thanks.


Our fix in 'getFieldItems' function @ modxroot/components/taxonomies/model/Base.php

Insert at line 184:
uasort($children, function($a, $b){return $a['menuindex'] - $b['menuindex'];});

Complete function:

public function getFieldItems($current_values,$children, $indent_multiplier = 0, $class = '')
{

    $out = '';

   // sort children
   uasort($children, function($a, $b){return $a['menuindex'] - $b['menuindex'];});

    foreach ($children as $page_id => $def) {
        $indent = str_repeat('--', $indent_multiplier);
        if (isset($def['published']) && $def['published'])
        {
            $checked = (in_array($page_id,$current_values)) ? ' checked="checked"' : '';
            $out .= $indent . ' <input type="checkbox" name="terms[]" id="terms' . $this->i . '" value="' . $page_id . '"
                class="multicheck' . $class . '" style=""  '.$checked.'/>
                <label for="terms' . $this->i . '" class="multichecklabel">' . $def['pagetitle'] . '</label><br/>';
            $this->i = $this->i + 1;
            if (!empty($def['children'])) {
                $class = $class . ' term' . $page_id;
                $out .= $this->getFieldItems($current_values,$def['children'], $indent_multiplier+1, $class);
            }
        }
        //$indent_multiplier--;
    }

    return $out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants