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

Request: Allow the galleries to be sorted by creation date #105

Open
Kikketer opened this issue Jul 8, 2022 · 4 comments
Open

Request: Allow the galleries to be sorted by creation date #105

Kikketer opened this issue Jul 8, 2022 · 4 comments

Comments

@Kikketer
Copy link
Contributor

Kikketer commented Jul 8, 2022

I'd like the ability to have the gallery items sort by created date instead of the arbitrary number assigned when created. I have a number of users creating the galleries and they aren't aware of what 200 means in sort order. Also we'd have to have the number slowly decrease which means you'd have to know what the most recent one is.

Proposal is to allow the owner/admin of the gallery create a setting to have the sort-order default to created date of the gallery (not any images in that gallery, just the gallery itself).

With this setting set to "created date" and possible "descending/ascending" the current sort order input box would be hidden on the gallery creation screens.

@Kikketer
Copy link
Contributor Author

@luke- do you have a step-by-step somewhere or at least a quick breakdown of how you have things like this setup for testing/development?

My current setup includes using docker for the php/mysql/apache setup. I then symlink the humhub modules directory for gallery to my fork of humhub-gallery.

I mostly ask because things seem to be working but at the same time any changes I'm doing to the gallery aren't reflecting in the site (I just did some crazy add a <p> tag in a view to see if it appears). Is there possibly a cache that needs to be cleared each time? Maybe using a symlink is an issue?

Perhaps it's another ticket to update the DEVELOPERS.md file.

@Kikketer
Copy link
Contributor Author

Ok so I simply removed the symlink, it seems to have been the issue (php was likely not following the symlink). But now I have maybe a general Yii question.

CustomGallery extends BaseGallery extends ContentActiveRecord
ContentActiveRecord has a created_at field (from what I understand what I'm looking at in the DB).

ListController extends BaseController

I attempted to simply update the protected $queryOrder to include the inherited value of created_at but it resolves to 0 in the resulting SQL query (which throws an error).
How do you access the inherited columns in the model from within the controller?

Where I'm at (this is not exactly where this will land, but trying to learn before throwing real code for the PR)

    protected $queryOrder = [
        // 'sort_order' => SORT_DESC,
        'created_at' => SORT_ASC, << Resolves to `0` (can't be found?)
        'title' => SORT_DESC, << Resolves properly to `title`
    ];

@luke-
Copy link
Contributor

luke- commented Jul 12, 2022

@Kikketer Did you saw this page? https://docs.humhub.org/docs/develop/environment

Unfortunately, I am not completely involved in the Gallery Module.
Problem here is probably that created_at comes from Content and the Sort Order from the BaseGallery model.
Solution would be to somehow give the relation to the ActiveDataProvider and change the sort order.

@Kikketer
Copy link
Contributor Author

I tried the instructions for the development setup but there was some issue with the php composer that failed to import the dependencies. I think the setup I have now works well enough, I'm able to build and debug.

Yeah the "somehow give the relation" is the part I'm hung up on. I tried stuff like content.created_at and the like but none of them worked out. I'll keep exploring, but it may also land in just creating a created_at column in the module and use that (which is unfortunate).

Thanks again for dealing with this "new to PHP developer".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants