jonom / silverstripe-betternavigator

Front-end utility menu for SilverStripe websites featuring administration and development tools
60 stars 31 forks source link

Add support for Silverstripe 5 #61

Closed chrispenny closed 1 year ago

chrispenny commented 1 year ago

Template namespace

Breaking change

Moved templates into JonoM namespace. Update renderWith() and <% include %> references.

Fixes #60 Closes #60

Upgrade actions: Developers will need to move any custom/overriding templates into a JonoM directory (matching what is documented in the README).

BetterNavigatorExtension changes

Breaking change

SilverStripeNavigator has moved namespace in Silverstripe 5. With that being the case, I don't believe we can support Silverstripe 4 and 5 at the same time? (Though I will be happy to be wrong).

shouldDisplay() cache change

The way that this cache was being set to a field seems to throw an error with Silverstripe 5:

ERROR [Warning]: Undefined array key "_betterNavigatorShouldDisplay"
IN GET /server-error
Line 220 in /var/www/mysite/www/vendor/silverstripe/framework/src/View/ViewableData.php

Using local/mem-cache on the Extension will achieve the same result.

BetterNavigator.ss changes

In Silverstripe 5 there is now a configuration to allow/disallow trailing slashes. For the Build databases and Dev menu links, it's easier to use relative links, as we then don't need to bother with checking if trailing slashes were present or not.

Trailing slash change: https://github.com/silverstripe/silverstripe-framework/pull/10538

jonom commented 1 year ago

Thanks for working on this @chrispenny. If you have a sec while you're dealing with namespaces you might want to take a peek at this issue, otherwise I'll aim to do that before we bump the version on this module.

chrispenny commented 1 year ago

Thanks, @jonom! I'll have a look today :D

chrispenny commented 1 year ago

Looks to be working with the suggested namespace change.

Template for each include: Screen Shot 2023-02-14 at 8 01 55 AM

New buttons added: Screen Shot 2023-02-14 at 8 01 40 AM

chrispenny commented 1 year ago

@jonom I believe this is ready for review :)

I've tested running my local in dev and test to check that the interface shows (or hides) at appropriate times, and the buttons all look to be linking correctly.

jonom commented 1 year ago

Awesome, thanks @chrispenny! Have tagged 6.0.0-beta1 and created a 5 branch.