Resolve
class Resolve (View source)
The Resolve class holds all methods to modulate URLs and file paths.
Since all page URLs are not URLs to real directories, all non-absolute links and file paths have to be resolved, to point to a valid location. For example a relative file name to an image wouldn't be a valid link, since the URL of the page is not the real file system path to the page's files.
Methods
Resolve absolute URLs (starting with a slash) to the domain.
Resolve absolute URLs (starting with a slash) to root in case Automad is installed within a subdirectory.
Resolve a file path or glob pattern according to its type (root relative or relative).
Resolve relative URLs (starting with a character or .) to be absolute URLs, using the base directory (where Automad is installed) as root.
Details
at line 65
static string
absoluteUrlToDomain(string $url)
Resolve absolute URLs (starting with a slash) to the domain.
Example: /page -> https://domain/base-url/index.php/page or /page -> https://domain/base-url/page
at line 79
static string
absoluteUrlToRoot(string $url)
Resolve absolute URLs (starting with a slash) to root in case Automad is installed within a subdirectory.
Example: /page -> /base-url/index.php/page or /page -> /base-url/page
at line 113
static string
filePath(string $pagePath, string $filePath)
Resolve a file path or glob pattern according to its type (root relative or relative).
If a file path begins with a '/', it is treated like a root relative path and the only AM_BASE_DIR gets prepended. In all other cases, the full path to the page gets prepended. For example a file called 'image.jpg' becomes '/basedir/pages/pagedir/image.jpg' and '/shared/image.jpg' becomes '/basedir/shared/image.jpg'.