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

Feature Request - Add "Sort by Random" into "Finder" #2588

Open
egloffmark opened this issue Dec 31, 2019 · 0 comments
Open

Feature Request - Add "Sort by Random" into "Finder" #2588

egloffmark opened this issue Dec 31, 2019 · 0 comments
Assignees

Comments

@egloffmark
Copy link

When you use the content finder i.e. for joomla articles, it is currently only possible to sort by article attributes, but you can not sort it by random. See http://docs.gantry.org/gantry5/advanced/content-in-particles#orderby-direction-asc-alias-a-pagination-order. The current implementation quite hard-coded so it would be good if you can pass a function or offer a random function.

in Twig

set article_finder = joomla.finder('content', article_options).published(1).language()
set articles = article_finder.order(sort.orderby, sort.ordering).limit(limit.total).start(limit.start).find()

Current "order()" Implementation, at "/libraries/gantry5/classes/Gantry/Joomla/Object/Finder.php"

    public function order($by, $direction = 1, $alias = 'a')
    {
        if (is_numeric($direction)) {
            $direction = $direction > 0 ? 'ASC' : 'DESC';
        } else {
            $direction = strtolower((string)$direction) == 'desc' ? 'DESC' : 'ASC';
        }
        $by = (string)$alias . '.' . $this->db->quoteName($by);
        $this->query->order("{$by} {$direction}");

        return $this;
    }
@mahagr mahagr self-assigned this Jan 2, 2020
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