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

Add custom page template class to backend to detect a current page template #13339

Closed
khoipro opened this issue Jan 16, 2019 · 13 comments
Closed
Labels
[Feature] Document Settings Document settings experience [Type] Enhancement A suggestion for improvement. [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.

Comments

@khoipro
Copy link
Contributor

khoipro commented Jan 16, 2019

Is your feature request related to a problem? Please describe.
I wish to create some full-width section and push them in a full-width template, but we need to match both backend and frontend styling. Currently, a default style in Gutenberg keep too narrow width and can't override for a custom page template.

Describe the solution you'd like
Add page template class after a page with a custom template was saved. It should be stay in one of these elements::

edit-post-visual-editor editor-styles-wrapper
edit-post-layout__content

For example, I can use:

.editor-styles-wrapper.template-page-fullwidth .wp-block {
  max-width: 100%;
}

It will help us keep a custom page template separate from other posts.

Describe alternatives you've considered

Looking for section method to replace it. Check #4900

@khoipro khoipro changed the title Add body class to backend to detect a current page template Add custom page template class to backend to detect a current page template Jan 16, 2019
@spencerfinnell
Copy link

@khoipro I made a plugin that does this:

https://github.com/bigboxwc/wp-editor-page-template-class
https://github.com/bigboxwc/wp-editor-page-template-class/releases/tag/1.0.0

@swissspidy swissspidy added [Type] Enhancement A suggestion for improvement. [Feature] Document Settings Document settings experience [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes. labels Jan 22, 2019
@khoipro
Copy link
Contributor Author

khoipro commented Jan 23, 2019

Thanks for your contribute @spencerfinnell, but I still something can be a Pull Request to Gutenberg, because it should be apart of core.

@dougwollison
Copy link
Contributor

dougwollison commented Jul 8, 2019

+1

I'd like the styles wrapper to also include the post type class; I frequently build sites where the base styling varies from post type to post type, not to mention simulating options like colorschemes and other options I may add controls for that need to be reflected in the visual editor.

I'm currently using a modified version of @spencerfinnell's solution, but it doesn't get re-applied when switching between Code and Visual mode, which while an edge case does make things annoying.

There needs to be some way of both detecting when the editor switches modes (spent all morning trying to find a way, no dice thus far), or otherwise one of the following:

  • register additional classes on the .editor-styles-wrapper div within the editor (with the ability add/remove them on the fly and have them preserved when toggling visual/code mode).
  • support for a special selector prefix that will prevent the editor from blindly rewriting all selectors in the editor-styles CSS to be prefixed with .editor-styles-wrapper.

@tatof
Copy link

tatof commented Oct 11, 2019

+1 This should indeed be a core function

@strarsis
Copy link
Contributor

+1!

@anteksiler
Copy link

+1

@strarsis
Copy link
Contributor

strarsis commented Feb 18, 2021

+1 again! This is important for feature-parity to the classic editor.

@tomphilpotts
Copy link

I have just come across this problem, trying to adjust the editor width for a specific page template. It doesn't make sense that this isn't in core.

@benedict-w
Copy link

+1

@dashkevych
Copy link

+1

It would be great to see this functionality in the core.

@khoipro
Copy link
Contributor Author

khoipro commented Oct 18, 2021

I believe this case is no longer need because with core/group we could wrap it well.

@khoipro khoipro closed this as completed Oct 18, 2021
@dougwollison
Copy link
Contributor

@khoipro could you elaborate? It sounds like you're suggesting manually wrapping an entire page's content in a group block and applying an arbitrary class to it, which I can't see as being a viable solution.

@anteksiler
Copy link

@khoipro it is not the same thing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Document Settings Document settings experience [Type] Enhancement A suggestion for improvement. [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.
Projects
None yet
Development

No branches or pull requests

10 participants