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

Remove a collection from the collection listing #259

Open
aerni opened this issue Aug 3, 2020 · 8 comments
Open

Remove a collection from the collection listing #259

aerni opened this issue Aug 3, 2020 · 8 comments

Comments

@aerni
Copy link

aerni commented Aug 3, 2020

I'm working on an addon that has a Collection of Products. I would like to move this Products Collection to its own dedicated Nav and remove it from the regular Collections Nav and Collections Listing.

I was able to remove it from the Collections Nav already. But couldn't find a way to remove it from the Collections Listing as well.

Nav::extend(function ($nav) {
  $nav->content('Collections')
    ->children(function () {
      return Collection::all()->sortBy->title()->filter(function ($item) {
        return $item->handle() !== 'products';
      })->map(function ($collection) {
        return Nav::item($collection->title())
          ->url($collection->showUrl())
          ->can('view', $collection);
      });
    });
});

Nav::extend(function ($nav) {
  $nav->create('Products')
    ->section('Snipcart')
    ->route('collections.show', 'products')
    ->icon('drawer-file');
});
@riasvdv
Copy link

riasvdv commented Aug 3, 2020

@jesseleite
Copy link
Member

There's a pretty good chance we'll be implementing pinned nav items. See the discussion in #74

@aerni
Copy link
Author

aerni commented Aug 4, 2020

That's not quite the same, is it? Pinned is great to use for certain collections for sure. But in this case, I'd like to create a whole new Section for an addon and add a collection there. Plus other custom menu items.

@jesseleite
Copy link
Member

jesseleite commented Aug 4, 2020

Yeah, your mileage is going to vary, as Nav::extend() isn't smart enough to deal with listing pages (and I'm not sure it should).

If you need to remove a collection from the Collections nav and listing, you might be able to extend CollectionRepository and bind your implementation to the container (see https://statamic.dev/extending/repositories). Could get messy though, especially within an addon where your end user (or another addon) might be intentionally binding their own CollectionRepository extension.

If there's a valid enough use case, it might be better to have some kind of hide: true or listable: false setting to a collection's yaml file, to hide the collection from nav and listings automatically. Would have to think through implications across the control panel though (ie. permissions, etc).

@aerni
Copy link
Author

aerni commented Aug 5, 2020

Yeah, something like listable: false could make sense.

@jesseleite jesseleite changed the title Move Collection to its own Nav Remove a collection from the collection listing Aug 5, 2020
@jackabox
Copy link

jackabox commented Mar 2, 2021

Hey, did you ever find a way to solve this? Wanting to remove a collection myself from the nav/collection overview page but failing.

@aerni
Copy link
Author

aerni commented Mar 2, 2021

No, there's currently no solution for this.

@kevinmeijer97
Copy link

Hi! I wanted to follow up on this topic.

In PR #80, we're building runway resources to link Magento categories and products. We aim to enhance these resources by adding custom fields without modifying the Magento database tables. To achieve this, we linked a collection to each runway resource so that the resource displays the fields from the collection.

The only issue we’re facing now is that we’d like to hide these collections from users, as they’re editing the data directly on the runway resource and don’t need to see the collections.

Since PR #3325 was closed a few years ago, would it be possible to reconsider adding this feature?

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

Successfully merging a pull request may close this issue.

5 participants