# Template Variables Reference Templates have access to a set of variables provided by FolderWeb and its plugins. This reference documents all available variables and their types. ## Base Template Variables Available in `base.php`: ### `$content` The fully rendered HTML content from the page or list template. **Type:** String (HTML) **Example:** ```php
``` ### `$pageTitle` The page title for the `` tag. **Type:** String **Default:** `"FolderWeb"` **Example:** ```php <title><?= htmlspecialchars($pageTitle ?? 'FolderWeb') ?> ``` **Source:** 1. Language-specific metadata `[lang] title` 2. Root metadata `title` 3. First heading in content 4. Folder name ### `$metaDescription` SEO description for the `` tag. **Type:** String **Optional:** May be empty **Example:** ```php ``` **Source:** 1. Metadata `search_description` 2. Metadata `summary` 3. Empty if not set ### `$socialImageUrl` URL to cover image for social media meta tags. **Type:** String (URL) **Optional:** May be empty **Example:** ```php ``` **Source:** First `cover.*` image found in content directory ### `$navigation` Array of navigation menu items. **Type:** Array of associative arrays **Structure:** ```php [ ['url' => '/about/', 'title' => 'About'], ['url' => '/blog/', 'title' => 'Blog'], ['url' => '/contact/', 'title' => 'Contact'], ] ``` **Example:** ```php ``` **Source:** Pages with `menu = 1` in metadata, sorted by `menu_order` ### `$homeLabel` Text for the home link. **Type:** String **Default:** `"Home"` **Example:** ```php ``` **Source:** Translation string `translations['home']` or fallback "Home" ### `$currentLang` Current language code. **Type:** String **Default:** From `config.ini` `languages.default` **Example:** ```php ``` **Values:** ISO 639-1 language codes (`en`, `no`, `de`, etc.) ### `$langPrefix` URL prefix for the current language. **Type:** String **Default:** Empty string for default language **Example:** ```php Home ``` **Values:** - `""` (empty) for default language - `"/no"` for Norwegian - `"/de"` for German - etc. ### `$languageUrls` URLs to switch between available languages. **Type:** Associative array **Structure:** ```php [ 'en' => '/page/', 'no' => '/no/side/', 'de' => '/de/seite/', ] ``` **Example:** ```php 1): ?> ``` ### `$translations` Translated UI strings for the current language. **Type:** Associative array **Structure:** ```php [ 'home' => 'Home', 'footer_handcoded' => 'Generated in', 'footer_page_time' => 'ms', 'months' => 'January,February,March,...', ] ``` **Example:** ```php

``` **Source:** Language files in `custom/languages/[lang].ini` or `app/default/languages/[lang].ini` ### `$pageCssUrl` URL to page-specific CSS file. **Type:** String (URL) **Optional:** Only set if `styles.css` exists in content directory **Example:** ```php ``` ### `$pageCssHash` MD5 hash of page-specific CSS for cache busting. **Type:** String (MD5 hash) **Optional:** Only set if `$pageCssUrl` exists **Example:** See `$pageCssUrl` above ### `$pageJsUrl` URL to page-specific JavaScript file. **Type:** String (URL) **Optional:** Only set if `script.js` exists in content directory **Example:** ```php ``` ### `$pageJsHash` MD5 hash of page-specific JavaScript for cache busting. **Type:** String (MD5 hash) **Optional:** Only set if `$pageJsUrl` exists **Example:** See `$pageJsUrl` above ### `$feedUrl` URL to the Atom feed for the current list page. **Type:** String (URL path) **Optional:** Only set on list pages with `feed = true` in metadata **Example:** ```php ``` **Source:** Set when `feed = true` in the list directory's `metadata.ini` ## Page Template Variables Available in `page.php`: ### `$content` The fully rendered HTML content from the page. **Type:** String (HTML) **Example:** ```php
``` ### `$metadata` All metadata for the current page. **Type:** Associative array **Structure:** ```php [ 'title' => 'Page Title', 'summary' => 'Short description', 'date' => '2024-12-15', 'show_date' => true, 'author' => 'Jane Doe', // Custom fields 'tags' => 'web,design', // ... all other metadata fields ] ``` **Example:** ```php

``` ## List Template Variables Available in `list.php`, `list-grid.php`, `list-compact.php`, etc.: ### `$pageContent` Optional intro content from the directory's own files. **Type:** String (HTML) **Optional:** May be empty **Example:** ```php
``` **Source:** Content files in the list directory itself (not subdirectories) ### `$items` Array of items to display in the list. **Type:** Array of associative arrays **Structure:** ```php [ [ 'title' => 'My Post', 'url' => '/blog/my-post/', 'date' => '15. desember 2024', // Formatted for display 'rawDate' => '2024-12-15', // ISO YYYY-MM-DD 'summary' => 'Short description', 'cover' => '/blog/2024-12-15-my-post/cover.jpg', 'pdf' => null, 'redirect' => null, 'dirPath' => '/path/to/content/blog/2024-12-15-my-post', ], // ... more items ] ``` **Example:** ```php
<?= htmlspecialchars($item['title']) ?>

``` ### `$metadata` Metadata for the list directory itself. **Type:** Associative array **Structure:** Same as page metadata **Example:** ```php

``` ## Item Properties Each item in `$items` has these properties: | Property | Type | Description | Optional | |----------|------|-------------|----------| | `title` | String | Item title (from metadata, heading, or folder name) | No | | `url` | String | Full URL to the item (with trailing slash + lang prefix) | No | | `date` | String | Formatted date string (plugin-processed for display) | Yes | | `rawDate` | String | ISO date (YYYY-MM-DD) for feeds and `