mirror of
https://github.com/jonom/silverstripe-betternavigator.git
synced 2024-10-22 14:05:51 +02:00
Use locally scoped render for navigator, add shouldShowBetterNavigator() method
This commit is contained in:
parent
22d21d1050
commit
8ff71fdbfb
@ -42,9 +42,10 @@ class BetterNavigatorExtension extends DataExtension
|
||||
*/
|
||||
protected function generateNavigator()
|
||||
{
|
||||
|
||||
// Make sure this is a page
|
||||
if (!$this->isAPage()) return false;
|
||||
if (!$this->isAPage() || !$this->owner->showBetterNavigator()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only show navigator to appropriate users
|
||||
$isDev = Director::isDev();
|
||||
@ -94,10 +95,11 @@ class BetterNavigatorExtension extends DataExtension
|
||||
]);
|
||||
|
||||
// Merge with page data, send to template and render
|
||||
$bNData = new ArrayData($bNData);
|
||||
$page = $this->owner->customise(['BetterNavigator' => $bNData]);
|
||||
return $page->renderWith('BetterNavigator\\BetterNavigator');
|
||||
$navigator = new ArrayData($bNData);
|
||||
|
||||
return $navigator->renderWith('BetterNavigator\\BetterNavigator');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -138,6 +140,15 @@ class BetterNavigatorExtension extends DataExtension
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override on a per-controller basis to add custom logic
|
||||
* @return bool
|
||||
*/
|
||||
public function showBetterNavigator(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
|
@ -3,19 +3,16 @@
|
||||
|
||||
<div id="BetterNavigator" class="collapsed">
|
||||
|
||||
<% with $BetterNavigator %>
|
||||
<div id="BetterNavigatorStatus" class="$Viewing">
|
||||
<span class="bn-icon-cog"></span>
|
||||
$Viewing
|
||||
<span class="bn-icon-close"></span>
|
||||
</div>
|
||||
<% end_with %>
|
||||
|
||||
<div id="BetterNavigatorContent">
|
||||
|
||||
<div class="bn-links">
|
||||
|
||||
<% with $BetterNavigator %>
|
||||
<% if $ArchiveLink.Active %>
|
||||
<% if $EditLink %><a href="$EditLink" target="_blank"><span class="bn-icon-edit"></span>Restore</a><% end_if %>
|
||||
<% else %>
|
||||
@ -42,19 +39,18 @@
|
||||
<% else %>
|
||||
<a href="$LoginLink"><span class="bn-icon-user"></span>Log in</a>
|
||||
<% end_if %>
|
||||
<% end_with %>
|
||||
|
||||
</div>
|
||||
|
||||
<% include BetterNavigator\BetterNavigatorExtraContent %>
|
||||
|
||||
<% if $BetterNavigator.Mode=='dev' || $BetterNavigator.IsDeveloper %>
|
||||
<% if $Mode=='dev' || $IsDeveloper %>
|
||||
|
||||
<div class="bn-heading">Developer tools</div>
|
||||
|
||||
<div class="bn-links">
|
||||
|
||||
<% if $BetterNavigator.Mode='dev' %>
|
||||
<% if $Mode='dev' %>
|
||||
<span class="bn-disabled" title="Log out to end Dev Mode"><span class="bn-icon-tick"></span>Dev mode on</span>
|
||||
<% else %>
|
||||
<a href="{$AbsoluteLink}?isDev=1"><span class="bn-icon-devmode"></span>Dev mode</a>
|
||||
|
Loading…
Reference in New Issue
Block a user