diff --git a/CHANGELOG.md b/CHANGELOG.md index 496794b..59069f9 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Release Notes for Craft User Manual +## 5.0.4 - 2025-02-05 +- Adding in ability to add a custom URL segment to the user manual documentation section. + ## 5.0.3 - 2025-02-05 - Removing requirement for documentation to have URLs. [PR #48](https://github.com/RobErskine/Craft-User-Manual/pull/48) diff --git a/README.md b/README.md index eb5b818..1d57f9c 100755 --- a/README.md +++ b/README.md @@ -83,6 +83,8 @@ This plugin was inspired by the team over at [70kft](http://70kft.com/) for thei ## Releases See CHANGELOG.md for full release history. + +* **5.0.4** - Adding in ability to customize URL segment of the user manual documentation section * **5.0.3** - Merging PRs from [JorgeAnzola](https://github.com/JorgeAnzola) to remove requirement for User Manual entries to require URLs * **5.0.2** - Replacing `addExtension` with Craft Hook * **5.0.1** - Required "section" config setting to be an integer. Added "enabledSideBar" config setting to enable/disable the sidebar on the manual page. This fix is to help address possible issue in Craft 4 to Craft 5 migration. diff --git a/src/UserManual.php b/src/UserManual.php index 17e5b19..c180f26 100644 --- a/src/UserManual.php +++ b/src/UserManual.php @@ -30,7 +30,7 @@ use roberskine\usermanual\twigextensions\UserManualTwigExtension; /** - * Class Usermanual + * Class UserManual * * @author Rob Erskine * @package Usermanual @@ -106,6 +106,16 @@ function (Event $event) { ); } + /** + * @inheritdoc + */ + public function getCpNavItem(): ?array + { + $item = parent::getCpNavItem(); + $item['url'] = '/admin/' . $this->getSettings()->urlSegment; + return $item; + } + /** * Returns the user-facing name of the plugin, which can override the name * in composer.json @@ -123,8 +133,10 @@ public function getName(): string public function registerCpUrlRules(RegisterUrlRulesEvent $event): void { + $urlSegment = $this->getSettings()->urlSegment; $rules = [ - 'usermanual/' => ['template' => 'usermanual/index'], + $urlSegment => ['template' => 'usermanual/index'], + $urlSegment . '/' => ['template' => 'usermanual/index'], ]; $event->rules = array_merge($event->rules, $rules); diff --git a/src/models/Settings.php b/src/models/Settings.php index c6a092e..61e2508 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -48,7 +48,10 @@ class Settings extends Model */ public bool $enabledSideBar = true; - + /** + * @var string + */ + public string $urlSegment = 'usermanual'; // Public Methods // ========================================================================= @@ -59,7 +62,7 @@ class Settings extends Model public function rules(): array { return [ - [['pluginNameOverride', 'templateOverride'], 'string'], + [['pluginNameOverride', 'templateOverride', 'urlSegment'], 'string'], ['section', 'number'], ['enabledSideBar', 'boolean'] ]; diff --git a/src/templates/index.twig b/src/templates/index.twig index 69c02de..07d6c19 100644 --- a/src/templates/index.twig +++ b/src/templates/index.twig @@ -1,4 +1,3 @@ - {% extends "_layouts/cp" %} {% set title = craft.userManual.name|t %} @@ -21,10 +20,10 @@ {% set help = craft.entries.sectionId(sectionSelected).all() %}