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

Hide (modular) page types in Admin automagically #1828

Closed
fosil opened this issue Feb 7, 2020 · 6 comments
Closed

Hide (modular) page types in Admin automagically #1828

fosil opened this issue Feb 7, 2020 · 6 comments

Comments

@fosil
Copy link

fosil commented Feb 7, 2020

It would be nice if it was not necessary to enter all types individually, but to set a certain naming convention. E.g. ignore all templates with name starting with underscore - e.g. _templateto_be_ignored.html.twig.

Ideally with a switch in plugin settings that can enable/disable this feature.

Have you considered something like this?

Thx

@rhukster
Copy link
Member

Where in the admin are you referring to exactly?

@mahagr
Copy link
Member

mahagr commented Mar 4, 2020

I think he refers the admin plugin settings where you can hide page types. That said, I don't think there is really need for that -- there is an event for plugins which you can hook into and remove the types you don't want to be listed.

@w00fz
Copy link
Member

w00fz commented Nov 21, 2020

I think what @fosil means is to have a way to specify a pattern in the admin setting @mahagr is mentioning.

Right now you have to select all the templates one by one but in the input field if you were to type _templates_* as a pattern, it would automatically ignore any template named like that.

I personally do not find this much useful, but I have never found myself needing to hide any template, let alone a multitude of templates based on a pattern.

@fosil
Copy link
Author

fosil commented Nov 21, 2020

My most common use case is:
I will create websites for customers. Some pages are unique (Homepage, Blog item list, etc.) - in them the customer changes the content, but is not allowed to add another page of the same type. Others, on the other hand, must add (blog post). Since the number of unique ones is usually larger, it would be easier for me (also because of the easy orientation in the template files) to define some naming convention for ignoring in the Admin plugin than to list each one. Like _unique_*

w00fz added a commit that referenced this issue Nov 21, 2020
…in" and "Hide modular page types in Admin" settings (fixes #1828)
@w00fz
Copy link
Member

w00fz commented Nov 21, 2020

This is implemented in 1.10 now. You will be now able to pass regex as values to fine tune what to hide. It adds very little overhead because by default it will always try to match a value to an existing entry but the fallback now is for regexp.

Here is an example for page types:

Imagine i have 2 page types issue-1234 and issue-abcd. You can now set it to issue-* and none will display.
Alternatively you can also decide to only hide the numerical ones, in which case you would specify issue-\d (\d = digits) or to only hide the alpha one, you could do issue-\D (\D = non digits).

No Selection Wildcard Selection Digit Selection Non-digit Selection
Plugin: Admin Panel - Grav 2020-11-21 15-24-37 Plugin: Admin Panel - Grav 2020-11-21 15-25-31 Plugin: Admin Panel - Grav 2020-11-21 15-23-27 Plugin: Admin Panel - Grav 2020-11-21 15-22-04

And the same works for the modules:

No Selection Regex Selection
Plugin: Admin Panel - Grav 2020-11-21 15-32-41 Plugin: Admin Panel - Grav 2020-11-21 15-33-36

Hopefully this is what you were looking for!

@w00fz w00fz closed this as completed Nov 21, 2020
@fosil
Copy link
Author

fosil commented Nov 22, 2020

Wow, that's great news for me! And I think not just for me. Thanks!

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

4 participants