mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
Correct title generation for index files in entity root
Previously would output the language code as the title 'En'. This double checks whether the file is at the root of the entity and if so, it'll use the entity name.
This commit is contained in:
parent
804c67dcaf
commit
508238a7b2
@ -14,10 +14,7 @@ class DocumentationFolder extends DocumentationPage {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTitle() {
|
public function getTitle() {
|
||||||
$path = explode(DIRECTORY_SEPARATOR, trim($this->getPath(), DIRECTORY_SEPARATOR));
|
return $this->getTitleFromFolder();
|
||||||
$folderName = array_pop($path);
|
|
||||||
|
|
||||||
return DocumentationHelper::clean_page_name($folderName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -103,18 +103,30 @@ class DocumentationPage extends ViewableData {
|
|||||||
$page = DocumentationHelper::clean_page_name($this->filename);
|
$page = DocumentationHelper::clean_page_name($this->filename);
|
||||||
|
|
||||||
if($page == "Index") {
|
if($page == "Index") {
|
||||||
// look at the folder name
|
return $this->getTitleFromFolder();
|
||||||
$parts = explode("/", $this->getPath());
|
|
||||||
array_pop($parts); // name
|
|
||||||
|
|
||||||
$page = DocumentationHelper::clean_page_name(
|
|
||||||
array_pop($parts)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTitleFromFolder() {
|
||||||
|
$folder = $this->getPath();
|
||||||
|
$entity = $this->getEntity()->getPath();
|
||||||
|
|
||||||
|
$folder = str_replace('index.md', '', $folder);
|
||||||
|
|
||||||
|
// if it's the root of the entity then we want to use the entity name
|
||||||
|
// otherwise we'll get 'En' for the entity folder
|
||||||
|
if($folder == $entity) {
|
||||||
|
return $this->getEntity()->getTitle();
|
||||||
|
} else {
|
||||||
|
$path = explode(DIRECTORY_SEPARATOR, trim($folder, DIRECTORY_SEPARATOR));
|
||||||
|
$folderName = array_pop($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DocumentationHelper::clean_page_name($folderName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user