MG 2.2 Any way to change default sorting in an album

Solution
I am using this addon which allows me to achieve it manually https://xenforo.com/community/threads/xfmg-order-by-title.180369/
Glad it works for you, but this addon does not follow resource standards at all :-/

What you want to do can be achieved by editing the class XFMG\Repository\Media:

find:

PHP:
    public function findMediaForAlbum($albumId, array $limits = [])
    {
        $finder = $this->findMediaForList($limits);
        $finder->inAlbum($albumId);

        return $finder;
    }

replace with:
PHP:
    public function findMediaForAlbum($albumId, array $limits = [])
    {
        $finder = $this->findMediaForList($limits);
        $finder->inAlbum($albumId);

        $finder->orderByDate('title', 'ASC')...

nocte

Well-known member
I am using this addon which allows me to achieve it manually https://xenforo.com/community/threads/xfmg-order-by-title.180369/
Glad it works for you, but this addon does not follow resource standards at all :-/

What you want to do can be achieved by editing the class XFMG\Repository\Media:

find:

PHP:
    public function findMediaForAlbum($albumId, array $limits = [])
    {
        $finder = $this->findMediaForList($limits);
        $finder->inAlbum($albumId);

        return $finder;
    }

replace with:
PHP:
    public function findMediaForAlbum($albumId, array $limits = [])
    {
        $finder = $this->findMediaForList($limits);
        $finder->inAlbum($albumId);

        $finder->orderByDate('title', 'ASC');

        return $finder;
    }

In other words: You add the line $finder->orderByDate('title', 'ASC'); - does not make sense semantically, but works :)

Of course this is an ugly hack and should be done via an addon.
 
Solution
Thank you very much!

I have another question then that would have me set perfectly.

I see the function findMediaInCategory() is there a way to make it so that if the category ID = 1, 2, or 3 then it will also order by title the same way otherwise it will stick to the standard most-recent ordering?

Im sure I could figure it out with enough time... but I have never been very good with functions and object based programing.

Thank you again for all your help.
 
Top