lib/Pico.php
public function load404Content($file)
    {
        $contentDir = $this->getConfig('content_dir');
        $contentDirLength = strlen($contentDir);
        $contentExt = $this->getConfig('content_ext');

        if (substr($file, 0, $contentDirLength) === $contentDir) {
            $errorFileDir = substr($file, $contentDirLength);

            while ($errorFileDir !== '.') {
                $errorFileDir = dirname($errorFileDir);
                $errorFile = $errorFileDir . '/404' . $contentExt;

                if (file_exists($contentDir . $errorFile)) {
                    return $this->loadFileContent($contentDir . $errorFile);
                }
            }
        } elseif (file_exists($contentDir . '404' . $contentExt)) {
            // provided that the requested file is not in the regular
            // content directory, fallback to Pico's global `404.md`
            return $this->loadFileContent($contentDir . '404' . $contentExt);
        }

        // fallback to built-in error message
        $rawErrorContent = "---\n"
            . "Title: Error 404\n"
            . "Robots: noindex,nofollow\n"
            . "---\n\n"
            . "# Error 404\n\n"
            . "Woops. Looks like this page doesn't exist.\n";
        return $rawErrorContent;
    }
public function load404Content($file)
    {
        $contentDir = $this->getConfig('content_dir');
        $contentDirLength = strlen($contentDir);
        $contentExt = $this->getConfig('content_ext');

        if (substr($file, 0, $contentDirLength) === $contentDir) {
            $errorFileDir = substr($file, $contentDirLength);

            while ($errorFileDir !== '.') {
                $errorFileDir = dirname($errorFileDir);
                $errorFile = $errorFileDir . '/404' . $contentExt;

                if (file_exists($contentDir . $errorFile)) {
                    return $this->loadFileContent($contentDir . $errorFile);
                }
            }
        } elseif (file_exists($contentDir . '404' . $contentExt)) {
            // provided that the requested file is not in the regular
            // content directory, fallback to Pico's global `404.md`
            return $this->loadFileContent($contentDir . '404' . $contentExt);
        }

        // fallback to built-in error message
        $rawErrorContent = "---\n"
            . "Title: Error 404\n"
            . "Robots: noindex,nofollow\n"
            . "---\n\n"
            . "# Error 404\n\n"
            . "Woops. Looks like this page doesn't exist.\n";
        return $rawErrorContent;
    }
public function load404Content ( $ file ) { $ contentDir = $ this -> getConfig ( 'content_dir' ) ; $ contentDirLength = strlen ( $ contentDir ) ; $ contentExt = $ this -> getConfig ( 'content_ext' ) ; if ( substr ( $ file , 0 , $ contentDirLength ) === $ contentDir ) { $ errorFileDir = substr ( $ file , $ contentDirLength ) ; while ( $ errorFileDir !== '.' ) { $ errorFileDir = dirname ( $ errorFileDir ) ; $ errorFile = $ errorFileDir . '/404' . $ contentExt ; if ( file_exists ( $ contentDir . $ errorFile ) ) { return $ this -> loadFileContent ( $ contentDir . $ errorFile ) ; } } } elseif ( file_exists ( $ contentDir . '404' . $ contentExt ) ) { // provided that the requested file is not in the regular // content directory, fallback to Pico's global `404.md` return $ this -> loadFileContent ( $ contentDir . '404' . $ contentExt ) ; } // fallback to built-in error message $ rawErrorContent = "---\n" . "Title: Error 404\n" . "Robots: noindex,nofollow\n" . "---\n\n" . "# Error 404\n\n" . "Woops. Looks like this page doesn't exist.\n" ; return $ rawErrorContent ; }
Returns the raw contents of the first found 404 file when traversing
up from the directory the requested file is in

If no suitable `404.md` is found, fallback to a built-in error message.

@see Pico::getRawContent()

@param string $file path to requested (but not existing) file

@return string raw contents of the 404 file
Returns the raw contents of the first found 404 file when traversing up from the directory the requested file is in