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()
|
protected function generateNavigator()
|
||||||
{
|
{
|
||||||
|
|
||||||
// Make sure this is a page
|
// 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
|
// Only show navigator to appropriate users
|
||||||
$isDev = Director::isDev();
|
$isDev = Director::isDev();
|
||||||
@ -94,10 +95,11 @@ class BetterNavigatorExtension extends DataExtension
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Merge with page data, send to template and render
|
// Merge with page data, send to template and render
|
||||||
$bNData = new ArrayData($bNData);
|
$navigator = new ArrayData($bNData);
|
||||||
$page = $this->owner->customise(['BetterNavigator' => $bNData]);
|
|
||||||
return $page->renderWith('BetterNavigator\\BetterNavigator');
|
return $navigator->renderWith('BetterNavigator\\BetterNavigator');
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +140,15 @@ class BetterNavigatorExtension extends DataExtension
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override on a per-controller basis to add custom logic
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function showBetterNavigator(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
@ -3,19 +3,16 @@
|
|||||||
|
|
||||||
<div id="BetterNavigator" class="collapsed">
|
<div id="BetterNavigator" class="collapsed">
|
||||||
|
|
||||||
<% with $BetterNavigator %>
|
|
||||||
<div id="BetterNavigatorStatus" class="$Viewing">
|
<div id="BetterNavigatorStatus" class="$Viewing">
|
||||||
<span class="bn-icon-cog"></span>
|
<span class="bn-icon-cog"></span>
|
||||||
$Viewing
|
$Viewing
|
||||||
<span class="bn-icon-close"></span>
|
<span class="bn-icon-close"></span>
|
||||||
</div>
|
</div>
|
||||||
<% end_with %>
|
|
||||||
|
|
||||||
<div id="BetterNavigatorContent">
|
<div id="BetterNavigatorContent">
|
||||||
|
|
||||||
<div class="bn-links">
|
<div class="bn-links">
|
||||||
|
|
||||||
<% with $BetterNavigator %>
|
|
||||||
<% if $ArchiveLink.Active %>
|
<% if $ArchiveLink.Active %>
|
||||||
<% if $EditLink %><a href="$EditLink" target="_blank"><span class="bn-icon-edit"></span>Restore</a><% end_if %>
|
<% if $EditLink %><a href="$EditLink" target="_blank"><span class="bn-icon-edit"></span>Restore</a><% end_if %>
|
||||||
<% else %>
|
<% else %>
|
||||||
@ -42,19 +39,18 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<a href="$LoginLink"><span class="bn-icon-user"></span>Log in</a>
|
<a href="$LoginLink"><span class="bn-icon-user"></span>Log in</a>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
<% end_with %>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% include BetterNavigator\BetterNavigatorExtraContent %>
|
<% include BetterNavigator\BetterNavigatorExtraContent %>
|
||||||
|
|
||||||
<% if $BetterNavigator.Mode=='dev' || $BetterNavigator.IsDeveloper %>
|
<% if $Mode=='dev' || $IsDeveloper %>
|
||||||
|
|
||||||
<div class="bn-heading">Developer tools</div>
|
<div class="bn-heading">Developer tools</div>
|
||||||
|
|
||||||
<div class="bn-links">
|
<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>
|
<span class="bn-disabled" title="Log out to end Dev Mode"><span class="bn-icon-tick"></span>Dev mode on</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="{$AbsoluteLink}?isDev=1"><span class="bn-icon-devmode"></span>Dev mode</a>
|
<a href="{$AbsoluteLink}?isDev=1"><span class="bn-icon-devmode"></span>Dev mode</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user