mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
FEATURE: allow 3 levels of navigation for the module. _getModulePages() should in theory support any depth of pages
This commit is contained in:
parent
1a5c88b469
commit
ef7c095533
@ -382,24 +382,9 @@ class DocumentationViewer extends Controller {
|
|||||||
if($page->Title != "Index") $linkParts[] = $page->Filename;
|
if($page->Title != "Index") $linkParts[] = $page->Filename;
|
||||||
|
|
||||||
$page->Link = $this->Link($linkParts);
|
$page->Link = $this->Link($linkParts);
|
||||||
|
|
||||||
$page->LinkingMode = 'link';
|
$page->LinkingMode = 'link';
|
||||||
$page->Children = false;
|
|
||||||
|
$page->Children = $this->_getModulePagesNested($page);
|
||||||
if(isset($this->Remaining[0])) {
|
|
||||||
if(strtolower($this->Remaining[0]) == $page->Filename) {
|
|
||||||
$page->LinkingMode = 'current';
|
|
||||||
|
|
||||||
if(is_dir($page->Path)) {
|
|
||||||
$children = DocumentationParser::get_pages_from_folder($page->Path);
|
|
||||||
foreach($children as $child) {
|
|
||||||
$child->Link = $this->Link(array($this->Remaining[0], $child->Filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
$page->Children = $children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,6 +394,45 @@ class DocumentationViewer extends Controller {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the module pages under a given page. Recursive call for {@link getModulePages()}
|
||||||
|
*
|
||||||
|
* @param ArrayData CurrentPage
|
||||||
|
* @param int Depth of page in the tree
|
||||||
|
*
|
||||||
|
* @return DataObjectSet|false
|
||||||
|
*/
|
||||||
|
private function _getModulePagesNested(&$page, $level = 0) {
|
||||||
|
// only support 2 more levels
|
||||||
|
if(isset($this->Remaining[$level])) {
|
||||||
|
|
||||||
|
if(strtolower($this->Remaining[$level]) == $page->Filename) {
|
||||||
|
|
||||||
|
// its either in this section or is the actual link
|
||||||
|
$page->LinkingMode = (isset($this->Remaining[$level + 1])) ? 'section' : 'current';
|
||||||
|
|
||||||
|
if(is_dir($page->Path)) {
|
||||||
|
$children = DocumentationParser::get_pages_from_folder($page->Path);
|
||||||
|
|
||||||
|
$segments = array();
|
||||||
|
for($x = 0; $x <= $level; $x++) {
|
||||||
|
$segments[] = $this->Remaining[$x];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($children as $child) {
|
||||||
|
$child->Link = $this->Link(array_merge($segments, array($child->Filename)));
|
||||||
|
$child->LinkingMode = 'link';
|
||||||
|
$child->Children = $this->_getModulePagesNested($child, $level + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the content for the page. If its an actual documentation page then
|
* Return the content for the page. If its an actual documentation page then
|
||||||
* display the content from the page, otherwise display the contents from
|
* display the content from the page, otherwise display the contents from
|
||||||
|
@ -8,7 +8,15 @@
|
|||||||
<% if Children %>
|
<% if Children %>
|
||||||
<ul>
|
<ul>
|
||||||
<% control Children %>
|
<% control Children %>
|
||||||
<li><a href="$Link" class="$LinkingMode">$Title</a></li>
|
<li><a href="$Link" class="$LinkingMode">$Title</a>
|
||||||
|
<% if Children %>
|
||||||
|
<ul>
|
||||||
|
<% control Children %>
|
||||||
|
<li><a href="$Link" class="$LinkingMode">$Title</a></li>
|
||||||
|
<% end_control %>
|
||||||
|
</ul>
|
||||||
|
<% end_if %>
|
||||||
|
</li>
|
||||||
<% end_control %>
|
<% end_control %>
|
||||||
</ul>
|
</ul>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user