Skip to content

Option to bring back the Assets sidebar folders view #13535

Closed Answered by brandonkelly
elivz asked this question in Ideas
Discussion options

You must be logged in to vote

I don’t think we should have an officially supported way of bringing subfolders back into the source list, given the reasons we changed it in the first place. But modules/plugins are free to modify element sources via EVENT_REGISTER_SOURCES.

Here’s how you could do it in Craft 4.5 (pending this change):

use craft\base\Event;
use craft\elements\Asset;
use craft\events\RegisterElementSourcesEvent;
use craft\models\VolumeFolder;

// ...

private function attachEventHandlers(): void
{
    Event::on(Asset::class, Asset::EVENT_REGISTER_SOURCES, function(RegisterElementSourcesEvent $event) {
        $assetsService = Craft::$app->getAssets();

        foreach ($event->sources as &$source) {
     …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@elivz
Comment options

@brandonkelly
Comment options

@elivz
Comment options

@brandonkelly
Comment options

@elivz
Comment options

Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants