BUGFIX: Fixed duplicate Home links appearing

Added support for a home link in the menu when there is no default entity
This commit is contained in:
UndefinedOffset 2016-02-22 12:01:38 -04:00
parent d5f53864d7
commit d0fd100b79
3 changed files with 33 additions and 2 deletions

View File

@ -61,6 +61,11 @@ class DocumentationManifest
*/
private $entity;
/**
* @var boolean
*/
private $has_default_entity = false;
/**
* @var boolean
*/
@ -157,6 +162,9 @@ class DocumentationManifest
if (isset($details['DefaultEntity'])) {
$entity->setIsDefaultEntity($details['DefaultEntity']);
if ($entity->getIsDefaultEntity()) {
$this->has_default_entity = true;
}
}
$this->registeredEntities->push($entity);
@ -760,4 +768,13 @@ class DocumentationManifest
return $versions;
}
/**
* Gets whether there is a default entity or not
* @return boolean
*/
public function getHasDefaultEntity()
{
return $this->has_default_entity;
}
}

View File

@ -709,4 +709,14 @@ class DocumentationViewer extends Controller
{
return Config::inst()->get('DocumentationViewer', 'link_base');
}
/**
* Gets whether there is a default entity or not
* @return boolean
* @see DocumentationManifest::getHasDefaultEntity()
*/
public function getHasDefaultEntity()
{
return $this->getManifest()->getHasDefaultEntity();
}
}

View File

@ -3,10 +3,14 @@
$DocumentationSearchForm
<ul class="nav">
<% loop Menu %>
<% if not HasDefaultEntity %>
<li><a href="$Link" class="top">Home</a></li>
<% end_if %>
<% loop Menu %>
<% if DefaultEntity %>
<li><a href="$Link" class="top">Home</a></li>
<% loop Children %>
<li class="$LinkingMode <% if Last %>last<% end_if %>">
<a href="$Link" class="top">$Title</a>