wintercms / wn-pages-plugin

Static Pages plugin for Winter CMS
https://wintercms.com/
MIT License
9 stars 22 forks source link

Fix support for snippets in the default backend skin #44

Closed willouch closed 3 weeks ago

willouch commented 2 months ago

unhide snippets form area

Retrieve snippets in backend pages

LukeTowers commented 1 month ago

This would break the plugin when using TailwindUI, what is the underlying issue that's causing the problem?

ericp-mrel commented 1 month ago

In the latest release it looks like the data-content-id attribute value was changed from snippet to snippets and that broke the snippets section and are no longer visible.

https://github.com/wintercms/wn-pages-plugin/compare/v2.1.2...v2.1.3#diff-4cac0956d5e7331650b7a41c11f104d7f902592225b5afadb3739fa5d4a86e3aR23

Screenshot 2024-05-29 at 8 26 46 AM

I can confirm this PR fixes the issue by updating the sidebar nav item link to match the most recent change that was made.

LukeTowers commented 1 month ago

@ericp-mrel right, but it was changed from snippet to snippets because the exact same issue was occurring when using the Winter.TailwindUI plugin with this plugin except in reverse. Are you able to dig a bit further into what's causing the issue between the stock backend skin and the Tailwind UI skin that's causing it to break in one and work in the other?

ericp-mrel commented 1 month ago

It looks like problem is coming from the TailwindUI plugin where it's setting the data-menu-item attribute using a different value / source compared to the standard skin. It's setting the value of the data-menu-item from the sideMenu snippets array key rather than using the attributes array values.

Screenshot 2024-06-03 at 4 41 44 PM

Here's the default skin:

Here's where the standard skin is generating the attributes for the list item: https://github.com/wintercms/winter/blob/develop/modules/backend/layouts/_sidenav.php#L21

Screenshot 2024-06-03 at 4 49 44 PM

LukeTowers commented 3 weeks ago

Thanks for digging into this issue that deeply @ericp-mrel, that was very helpful! And it shows that this PR actually fixes it for both the standard and the TailwindUI skin, so that's awesome too :)

We should probably still improve how the attribute is generated (I prefer the approach in the TailwindUI plugin where it's automatically generated instead of manually specified in the menu item definition), but that's an issue for another day.