Compare commits

...

3 Commits

Author SHA1 Message Date
Jono Menz 15f0171e51
Update README.md 2023-06-22 16:28:47 -07:00
Jono Menz d40ee44938
Update README.md 2023-06-22 16:17:36 -07:00
Florian Thoma 5e99263c33 add namespace to config, fixes #63 2023-06-22 15:53:53 -07:00
3 changed files with 39 additions and 27 deletions

View File

@ -21,15 +21,15 @@ Silverstripe 5.0 (4.0+ and 3.1+ through previous releases)
## Installation
**Composer / Packagist ([best practice](http://doc.silverstripe.org/framework/en/trunk/installation/composer))**
Add "jonom/silverstripe-betternavigator" to your requirements.
Add "jonom/silverstripe-betternavigator" to your composer requirements.
```
composer require jonom/silverstripe-betternavigator
```
**Manually**
Download, place the folder in your project root, rename it to 'betternavigator' (if applicable) and run a dev/build?flush=1.
## Upgrading
* **6.0:** the namespace for this module's templates and configuration was changed in v6 to include a `JonoM` prefix. You may need to update your template directory structure and/or app configuration accordingly.
## How to use
@ -37,9 +37,22 @@ The navigator is auto-injected into your template, and no code changes are neede
If your website uses caching, make sure BetterNavigator's output is excluded.
## Custom navigator display logic
### Access developer tools on a live website
You can customise the navigator display logic using your own custom logic by defining a `showBetterNavigator(): bool`
You can mark certain CMS users as developers in your site's config, so they can access developer tools when logged in. Example YAML:
```
JonoM\BetterNavigator:
developers:
- 'dev@yoursite.com'
- 'otherdev@yoursite.com'
```
## Customisation
### Navigator display
You can control whether the navigator is displayed by defining a `showBetterNavigator(): bool`
method in any controller with the extension applied. By default the navigator will only show on controllers that have a `dataRecord` property that is an instance of `SilverStripe\CMS\Model\SiteTree`.
```php
@ -49,33 +62,26 @@ public function showBetterNavigator()
return $this->ShowDebugTools;
}
```
**Access developer tools on a live website**
You can mark certain CMS users as developers in your site's config, so they can access developer tools when logged in. Example YAML:
```
BetterNavigator:
developers:
- 'dev@yoursite.com'
- 'otherdev@yoursite.com'
```
## Customisation
### Layout options
BetterNavigator can be made translucent when collapsed by adding the following config setting:
```
BetterNavigator:
JonoM\BetterNavigator:
translucent: true
```
BetterNavigator's default position is 'right-top', but can be changed to 'right-bottom', 'left-top' or 'left-bottom'. Example:
```
BetterNavigator:
JonoM\BetterNavigator:
position: 'right-bottom'
```
BetterNavigator's output is controlled by templates so it can be [easily overridden](http://doc.silverstripe.org/framework/en/topics/theme-development#overriding).
### Template additions/overrides
BetterNavigator's output is controlled by templates so it can be [easily overridden](https://docs.silverstripe.org/en/5/developer_guides/templates/template_inheritance/#cascading-themes).
Some empty `<% include %>` placeholders are included to let you easily add more content (new buttons for instance). Just create any of these templates in your theme or app directory and add your content:
@ -85,7 +91,7 @@ Some empty `<% include %>` placeholders are included to let you easily add more
The BetterNavigator.ss template's scope is set to the page that is being viewed, so any methods available in your page controller will be available in the BetterNavigator.ss template. This should allow you to add custom links by page type and introduce complex logic if you want to.
## Overriding the "Edit in CMS" Link
### Overriding the "Edit in CMS" Link
There may be occasions when you wish to override the "Edit in CMS" link. For example to point to the edit form for a displayed DataObject, rather than for the Page itself. To do so, simply add a `BetterNavigatorEditLink()` method to your page's Controller, e.g.:
@ -105,7 +111,7 @@ public function BetterNavigatorEditLink()
(This example uses [sunnysideup/cms_edit_link_field](https://github.com/sunnysideup/silverstripe-cms_edit_link_field) to automatically find an edit link for a specified DataObject, but you can return any URL.)
## Overriding the permissions required for the cms edit link
### Overriding the permissions required for the cms edit link
By default users are required to have at least the `CMS_ACCESS_CMSMain` permission in order to see the edit link in better navigator, you can override this by setting the `better_navigator_edit_permission` configuration option on your controller to another permission code or an array of permission codes, e.g.:
@ -113,10 +119,17 @@ By default users are required to have at least the `CMS_ACCESS_CMSMain` permissi
My\Namespace\EventController:
better_navigator_edit_permission: "CUSTOM_PERMISSION_CODE"
better_navigator_edit_permission_mode: "any" #Optional, but can be either "any" or "all" (defaults to "all")
```
## Bonus: better debugging tools
## Recommended companions
This module provide quick access to Silverstripe's built in [URL Variable Tools](http://doc.silverstripe.org/framework/en/reference/urlvariabletools) but reading their output isn't much fun. You can peek under Silverstripe's hood much more conveniently using lekoala's [Silverstripe DebugBar](https://github.com/lekoala/silverstripe-debugbar)
### DebugBar for better debugging tools
This module provide quick access to Silverstripe's built in [URL Variable Tools](https://docs.silverstripe.org/en/developer_guides/debugging/url_variable_tools/#url-variable-tools) but reading their output isn't much fun. You can peek under Silverstripe's hood much more conveniently using lekoala's [Silverstripe DebugBar](https://github.com/lekoala/silverstripe-debugbar)
### Environment Awareness to save your sites from yourself
[Environment Awareness](https://github.com/jonom/silverstripe-environment-awareness) makes it obvious which environment you're in, to make it less likely that you nuke something in prod. You can display the current environment [right in the navigator](https://github.com/jonom/silverstripe-environment-awareness/blob/master/docs/en/how-to-use.md#include-front-end-environment-notice).
## Maintainer contact

View File

@ -19,7 +19,6 @@
"silverstripe/framework": "^5"
},
"extra": {
"installer-name": "betternavigator",
"expose": [
"css",
"images",

View File

@ -129,7 +129,7 @@ class BetterNavigatorExtension extends DataExtension
// Is the logged in member nominated as a developer?
$member = Security::getCurrentUser();
$devs = Config::inst()->get('BetterNavigator', 'developers');
$devs = Config::inst()->get('JonoM\BetterNavigator', 'developers');
$identifierField = Member::config()->unique_identifier_field;
$isDeveloper = $member && is_array($devs) ? in_array($member->{$identifierField}, $devs) : false;
@ -207,8 +207,8 @@ class BetterNavigatorExtension extends DataExtension
private function BetterNavigatorCssClass() {
$classes = '';
$position = Config::inst()->get('BetterNavigator', 'position');
$translucent = Config::inst()->get('BetterNavigator', 'translucent');
$position = Config::inst()->get('JonoM\BetterNavigator', 'position');
$translucent = Config::inst()->get('JonoM\BetterNavigator', 'translucent');
if ($position === 'left-top' || $position === 'left-bottom' || $position === 'right-bottom') {
$classes .= ' ' . $position;