This package provides a simple way to allow users to manage any Redirects for their Twill Sites.
This package requires Laravel 8 or higher, PHP8 or higher, and Twill 3.0 or higher.
First you want to install this dependency using composer, you can do this by running the following command:
$ composer require cwsdigital/twill-redirects
$ php artisan migrate
This package is set up to automatically register the Redirects Capsule and add it directly to the Twill Admin Navigation.
You may want to determine where to place the Redirects
module in your Twill Navigation, for example, you want Redirects to appear
as a secondary menu item within a primary navigation of Settings.
First you will need to publish the config file:
php artisan vendor:publish --provider="CwsDigital\TwillRedirects\TwillRedirectsServiceProvider" --tag=config
Secondly, change the 'automaticNavigation' to false. This will prevent Twill from automatically adding the Redirects Primary Navigation link.
TwillNavigation::addLink(
NavigationLink::make()->title('Settings')
->forModule('redirects')
->doNotAddSelfAsFirstChild()
->setChildren([
NavigationLink::make()->title('Redirects')->forModule('redirects'),
])
);
To make your frontend routing aware of the Redirect middleware you need to add this to the laravel middleware in Kernel.php
{{-- app/Http/Kernel.php --}}
protected $middleware = [
// Add HandlesPageRedirects::class
CwsDigital\TwillRedirects\Twill\Capsules\Redirects\Http\Middleware\HandlesPageRedirects::class,
];
There are two events triggered in the Redirect Middleware.
- RedirectWasFound event is triggered when a redirect has been found.
- RedirectWasNotFound event is triggered when no redirect was found.
Please see CHANGELOG for details.
The MIT License (MIT). Please see License File for more information.