diff --git a/code/DocumentationService.php b/code/DocumentationService.php index 737f54f..d612b73 100644 --- a/code/DocumentationService.php +++ b/code/DocumentationService.php @@ -552,6 +552,8 @@ class DocumentationService { $folder = Controller::join_links($base, $relative); + if(!is_dir($folder)) return false; + $handle = opendir($folder); if($handle) { diff --git a/code/DocumentationViewer.php b/code/DocumentationViewer.php index 1b089d1..3c9d5e1 100755 --- a/code/DocumentationViewer.php +++ b/code/DocumentationViewer.php @@ -492,11 +492,13 @@ class DocumentationViewer extends Controller { return DBField::create("HTMLText", $html); } else { - // if no page found then we may want to get the listing of - // the folder - if($url = $this->Remaining) { - $pages = DocumentationService::get_pages_from_folder($this->getModule(), implode('/', $url), false); - + // If no page found then we may want to get the listing of the folder. + // In case no folder exists, show a "not found" page. + $module = $this->getModule(); + $url = $this->Remaining; + if($url && $module) { + $pages = DocumentationService::get_pages_from_folder($module, implode('/', $url), false); + // If no pages are found, the 404 is handled in the same template return $this->customise(array( 'Title' => DocumentationService::clean_page_name(array_pop($url)), 'Pages' => $pages diff --git a/templates/DocFolderListing.ss b/templates/DocFolderListing.ss index 3490cb5..b9abd97 100644 --- a/templates/DocFolderListing.ss +++ b/templates/DocFolderListing.ss @@ -9,5 +9,5 @@ <% else %> -
Nothing to see here
+ <% include DocNotFound %> <% end_if %> \ No newline at end of file diff --git a/templates/Includes/DocNotFound.ss b/templates/Includes/DocNotFound.ss new file mode 100644 index 0000000..855c6ad --- /dev/null +++ b/templates/Includes/DocNotFound.ss @@ -0,0 +1,24 @@ +The page you are looking for does not exist, or might have moved. +
return to the homepage or try searching (see input box on the top right).
+ + +Woops page not found
+ <% include DocNotFound %> <% end_if %> + <% if Content %>