All Classes Functions Variables Pages
Automad\Core\Automad Class Reference

Public Member Functions

 __construct ($parseTxt=true)
 __sleep ()
 __wakeup ()
 getSiteData ($key)
 getSystemVar ($var)
 setSystemVar ($var, $value)
 getValue ($key)
 getCollection ()
 getPageByUrl ($url)
 getRequestedPage ()
 getFilelist ()
 getPagelist ()
 currentPageExists ()

Public Attributes


Private Member Functions

 makeUrl ($parentUrl, $slug)
 collectPages ($path= '/', $level=0, $parentUrl= '')
 createPage ($template, $title)

Private Attributes

 $Filelist = false
 $Pagelist = false
 $siteData = array()
 $collection = array()
 $systemVarBuffer = array()

Detailed Description

The Automad class includes all methods and properties regarding the site, structure and pages. A Automad object is the "main" object. It consists of many single Page objects and holds also additional data like the site's name and theme.

Marc Anton Dahmen hello.nosp@m.@mar.nosp@m.cdahm.nosp@m.en.d.nosp@m.e
MIT license -

Definition at line 53 of file automad.php.

Constructor & Destructor Documentation

Automad\Core\Automad::__construct (   $parseTxt = true)

Parse sitewide settings, create $collection and set the context to the currently requested page. If $parseTxt is false, parsing the content and the settings get skipped and only the site's structure gets determined. (Useful for GUI)


Definition at line 287 of file automad.php.

References Automad\Core\Automad\$parseTxt, Automad\Core\Automad\collectPages(), Automad\Core\Automad\getRequestedPage(), Automad\Core\Debug\log(), and Automad\Core\Parse\siteData().

Member Function Documentation

Automad\Core\Automad::__sleep ( )

Define properties to be cached.


Definition at line 312 of file automad.php.

References Automad\Core\Debug\log().

Automad\Core\Automad::__wakeup ( )

Set new Context after being restored from cache.

Definition at line 324 of file automad.php.

References Automad\Core\Automad\getRequestedPage(), and Automad\Core\Debug\log().

Automad\Core\Automad::collectPages (   $path = '/',
  $level = 0,
  $parentUrl = '' 

Searches $path recursively for files with the AM_FILE_EXT_DATA and adds the parsed data to $collection.

After successful indexing, the $collection holds basically all information (except media files) from all pages of the whole site. This makes searching and filtering very easy since all data is stored in one place. To access the data of a specific page within the $collection array, the page's url serves as the key: $this->collection['/path/to/page']


Definition at line 182 of file automad.php.

References Automad\Core\Parse\extractTags(), Automad\Core\Automad\getSiteData(), Automad\Core\Automad\makeUrl(), and Automad\Core\Parse\markdownFile().

Referenced by Automad\Core\Automad\__construct().

Automad\Core\Automad::createPage (   $template,

Create a temporary page on the fly (for example error page or search results).

temporary page object

Definition at line 551 of file automad.php.

References Automad\Core\Automad\getSiteData().

Referenced by Automad\Core\Automad\getPageByUrl().

Automad\Core\Automad::currentPageExists ( )

Tests wheter the currently requested page actually exists.

true if existing

Definition at line 571 of file automad.php.

References Automad\Core\Context\get().

Automad\Core\Automad::getCollection ( )

Return $collection array.

array $this->collection

Definition at line 454 of file automad.php.

References Automad\Core\Automad\$collection.

Referenced by Automad\Core\Toolbox\__construct().

Automad\Core\Automad::getFilelist ( )

Return Automad's instance of the Filelist class and create instance when accessed for the first time.

Filelist object

Definition at line 515 of file automad.php.

References Automad\Core\Automad\$Filelist.

Referenced by Automad\Core\Toolbox\filelist(), and Automad\Core\Automad\getSystemVar().

Automad\Core\Automad::getPageByUrl (   $url)

If existing, return the page object for the passed relative URL, else return error page.

object $page

Definition at line 468 of file automad.php.

References Automad\Core\Automad\createPage(), and Automad\Core\Parse\queryKey().

Referenced by Automad\Core\Automad\getRequestedPage().

Automad\Core\Automad::getPagelist ( )

Return Automad's instance of the Pagelist class and create instance when accessed for the first time.

Pagelist object

Definition at line 532 of file automad.php.

References Automad\Core\Automad\$Pagelist.

Referenced by Automad\Core\Automad\getSystemVar(), Automad\Core\Toolbox\listCount(), Automad\Core\Toolbox\pagelist(), Automad\Core\Toolbox\pagelistFilters(), and Automad\Core\Toolbox\pagelistMarkup().

Automad\Core\Automad::getRequestedPage ( )

Return the page object for the requested page.

object $currentPage

Definition at line 497 of file automad.php.

References Automad\Core\Automad\getPageByUrl().

Referenced by Automad\Core\Automad\__construct(), and Automad\Core\Automad\__wakeup().

Automad\Core\Automad::getSiteData (   $key)

Return a key from $this->siteData (sitename, theme, etc.).

string $this->siteData[$key]

Definition at line 339 of file automad.php.

Referenced by Automad\Core\Automad\collectPages(), Automad\Core\Automad\createPage(), and Automad\Core\Automad\getValue().

Automad\Core\Automad::getSystemVar (   $var)

Return the requeste system variable. System variables are all variables created by Automad at runtime and are related things like the context, the filelist and the pagelist objects or they are generated during loop constructs (current items like :file, :tag, etc. or the index :i).

the value of $var

Definition at line 357 of file automad.php.

References Automad\Core\Context\get(), Automad\Core\Automad\getFilelist(), and Automad\Core\Automad\getPagelist().

Referenced by Automad\Core\Automad\getValue().

Automad\Core\Automad::getValue (   $key)

Get the value of a given variable key - either from the page data, the site data or from the $_GET array.

The value

Definition at line 417 of file automad.php.

References Automad\Core\Context\get(), Automad\Core\Automad\getSiteData(), and Automad\Core\Automad\getSystemVar().

Referenced by Automad\Core\Toolbox\metaTitle(), and Automad\Core\Template\processContent().

Automad\Core\Automad::makeUrl (   $parentUrl,

Builds an URL out of the parent URL and the actual file system folder name.

It is important to only transform the actual folder name (slug) and not the whole path, because of handling possible duplicate parent folder names right. If there are for example two folders on the level above, called xxx.folder/ and yyy.folder/, they will be transformed into folder/ and folder-1/. If the URL from yyy.folder/child/ is made from the whole path, it will return folder/child/ instead of folder-1/child/, even if the parent URL would be folder-1/.

The prefix for sorting (xxx.folder) will be stripped. In case the resulting url is already in use, a suffix (-1, -2 ...) gets appende to the new url.

string $url

Definition at line 131 of file automad.php.

References Automad\Core\Parse\sanitize().

Referenced by Automad\Core\Automad\collectPages().

Automad\Core\Automad::setSystemVar (   $var,

Set a system variable.


Definition at line 403 of file automad.php.

Member Data Documentation

Automad\Core\Automad::$collection = array()

Array holding all the site's pages and the related data.

To access the data for a specific page, use the url as key: $this->collection['url'].

Definition at line 104 of file automad.php.

Referenced by Automad\Core\Sitemap\__construct(), Automad\Core\Pagelist\__construct(), Automad\Core\Sitemap\generate(), Automad\Core\Html\generateTree(), and Automad\Core\Automad\getCollection().


Automad's Context object.

The object is part of the Automad class to allow to access always the same instance of the Context class for all objects using the Automad object as parameter.

Definition at line 62 of file automad.php.

Referenced by Automad\Core\Filelist\__construct(), and Automad\Core\Pagelist\__construct().

Automad\Core\Automad::$Filelist = false

Automad's Filelist object

The object is part of the Automad class to allow to access always the same instance of the Filelist class for all objects using the Automad object as parameter.

Definition at line 71 of file automad.php.

Referenced by Automad\Core\Automad\getFilelist().

Automad\Core\Automad::$Pagelist = false

Automad's Pagelist object.

The object is part of the Automad class to allow to access always the same instance of the Pagelist class for all objects using the Automad object as parameter.

Definition at line 80 of file automad.php.

Referenced by Automad\Core\Automad\getPagelist(), Automad\Core\Toolbox\listCount(), and Automad\Core\Toolbox\pagelistMarkup().


Boolean, if true, the site's structure gets scanned as well as the site's content. Setting that variable to false will skip all txt files and its content parsing.

Definition at line 88 of file automad.php.

Referenced by Automad\Core\Automad\__construct().

Automad\Core\Automad::$siteData = array()

Array holding the site's settings.

Definition at line 95 of file automad.php.

Automad\Core\Automad::$systemVarBuffer = array()

Array holding all temporary system variable (those starting with a ":", like {[ :file ]}) being created in loops.

Definition at line 111 of file automad.php.

The documentation for this class was generated from the following file: