Table of Contents
Variables and constants available in FlatPress templates
This page documents the variables and constants that are actually exposed by FlatPress core to Smarty templates.
It is meant as a practical reference for:
- themes
- shared templates
- admin templates
- plugin templates
Plugin-specific variables are not listed exhaustively here. Any plugin may assign additional variables of its own.
How to access values
Smarty variables
Use normal Smarty syntax:
{$flatpress.title}
{$pagetitle}
{$subject}
PHP constants in Smarty
Use the built-in Smarty constant accessor:
{$smarty.const.BLOG_BASEURL}
{$smarty.const.ADMIN_DIR}
{$smarty.const.SYSTEM_VER}
{$smarty.const.PHP_VERSION}
Plugin templates
To include a template from a plugin, use the plugin: resource:
{include file="plugin:bbcode/toolbar"}
{include file="plugin:commentcenter/header"}
The first path segment is the plugin directory name inside fp-plugins/.
PLUGINNAME is therefore not a global FlatPress constant.
Scope and conventions
- FlatPress assigns some variables globally, for example
$flatpress,$lang,$pagetitleand$fp_config. - Other variables only exist in a specific context, for example inside an
{entry},{comment}or{static}block. - Admin templates receive their own set of variables such as
$panel,$actionand$panelstrings. - Some variables are created locally inside templates with
{assign}or{capture}. Those are documented separately at the end of this page.
Frontend
Global frontend variables
These variables are assigned by theme_init() and are available in normal frontend theme rendering.
| Variable | Type | Meaning |
|---|---|---|
$flatpress | array | Blog configuration plus some runtime values |
$lang | array | Active language strings |
$blogtitle | string | Alias of the configured blog title |
$pagetitle | string | Current HTML page title after FlatPress filters have run |
$fp_config | array | Full FlatPress configuration array |
The ''$flatpress'' array
$flatpress starts with the keys from $fp_config['general'] and then adds some runtime helpers.
Typical config-derived keys are:
titlesubtitlefooterwwwauthoremailstartpagemaxentriesnotifythemestyleblogidcharset
FlatPress also adds these runtime keys:
| Key | Type | Meaning |
|---|---|---|
loggedin | bool | Whether a user is currently logged in |
user | array | Current user data, only present when logged in |
themeurl | string | URL of the active theme or style directory |
params | array | Current parsed FlatPress request parameters |
For backward compatibility, FlatPress also creates uppercase aliases for the keys in $flatpress.
Example:
{$flatpress.title}
{$flatpress.TITLE}
Both forms refer to the same value.
Common frontend examples
{$flatpress.title}
{$flatpress.themeurl}imgs/logo.svg
{$flatpress.params.entry}
{$flatpress.user.userid}
{$fp_config.locale.lang}
{$smarty.const.BLOG_BASEURL}
Wrapper variables used by page templates
The following variables are used by wrapper templates such as default.tpl, comments.tpl, static.tpl, login.tpl, contact.tpl and search-related shared templates.
| Variable | Type | Meaning |
|---|---|---|
$subject | string | Main headline or current item title, depending on context |
$content | string | Main content or name of a shared template/resource |
$rawcontent | bool | Marks $content as raw content instead of a template name |
$static_id | string | Current static page id |
$static_page | array | Parsed static page data |
$error | array / string | Validation or form errors |
$success | int / bool | Success state used by forms and admin notices |
$values | array | Previously submitted form values |
$csrf_token | string | CSRF token for login, comments and contact forms |
$panelstrings | array | Small message array used by some shared templates |
$comment_formid | string | HTML id used by the comment form |
$user | string | Pre-filled login user name |
$noresults | bool | Search returned no matches |
Frontend block variables
Entry block variables
Inside an {entry} block, FlatPress assigns one entry at a time.
| Variable | Type | Meaning |
|---|---|---|
$id | string | Entry id |
$subject | string | Entry title |
$content | string | Entry content |
$date | string / int | Entry date/time value |
$author | string | Entry author |
$categories | array | Entry categories |
$comments | int | Comment count when requested by the current query |
$entry_commslock | bool | True if the entry has the special commslock category |
$version | string | Entry file format version, mainly internal |
Notes:
$commentsis only present when the query asks for comments or comment counts.- Additional entry fields assigned by plugins may also appear here.
Static page block variables
Inside a {static} block, FlatPress assigns one static page at a time.
| Variable | Type | Meaning |
|---|---|---|
$id | string | Static page id |
$subject | string | Page title |
$content | string | Page content |
$date | string / int | Page date |
$author | string | Page author |
$version | string | Page file format version |
Comment block variables
Inside a {comments} / {comment} context, FlatPress assigns one comment at a time.
| Variable | Type | Meaning |
|---|---|---|
$entryid | string | Entry id of the surrounding comment list |
$id | string | Comment id |
$subject | string | Comment subject |
$content | string | Comment text |
$date | string / int | Comment date/time value |
$name | string | Comment author name |
$url | string | Comment author URL |
$email | string | Comment author e-mail |
$loggedin | bool / string | Logged-in flag stored with the comment |
$version | string | Comment file format version |
$ip_address | string | Comment IP metadata, if available |
Note that comment keys with hyphens are normalized to underscores before they are assigned to Smarty.
Example: ip-address becomes $ip_address.
Widget block variables
Inside widget templates, FlatPress uses the following variables for each widget item:
| Variable | Type | Meaning |
|---|---|---|
$id | string | Widget id |
$subject | string | Widget title |
$content | string | Widget body |
Admin
Global admin variables
The admin area first sets admin-specific variables and then also runs theme_init() for the wrapper templates.
This means that admin templates usually have access to both the normal global FlatPress variables and the admin variables below.
| Variable | Type | Meaning |
|---|---|---|
$panel | string | Current admin panel |
$action | string | Current action inside the panel |
$panel_url | string | Base URL of the current panel |
$action_url | string | URL of the current panel action |
$subject | string | Admin page headline |
$menubar | array | Available admin panels |
$submenu | array | Available actions for the current panel, if any |
$actionname | string | Current action name |
$admin_panel_id | string | Internal PHP class name of the current admin action |
$success | int / bool | Success state for the current request |
$panelstrings | array | Language strings for the current panel/action |
$plang | array | Alias of $panelstrings |
Frequently used admin panel variables
The variables below are not global to every admin page, but they are assigned by core panels and are useful to know.
| Panel | Variables |
|---|---|
| Config | $themes, $lang_list, $charset_list, $static_list, $user |
| Entries | $entry, $post, $preview, $id, $draft, $saved_flags, $categories_all, $perpage_options, $perpage_current, $perpage_base_query |
| Static pages | $statics, $entry, $post, $preview, $id, $static_id |
| Themes / styles | $current_theme, $available_themes, $current_style, $available_styles |
| Uploader | $upload_limits, $uploaded_files, $upload_errors, $upload_warnings |
| Widgets | $fp_registered_widgets, $widgetlist, $oldwidgetlist, $pluginconf |
| Maintain | $apcu_available, $apcu_status, $apcu, $stableversion, $unstableversion, $notice, $phpinfo, $files |
| Plugins | $pluginlist, $enabledlist, $warnings |
Admin language helpers
In the admin area, labels usually come from $panelstrings or $plang:
{$panelstrings.head}
{$panelstrings.descr}
{$plang.author}
For wrapper navigation, admin templates may also use the global language array:
{$lang.admin.panels[$tab]}
{$lang.admin[$panel].submenu[$subtab]}
Constants commonly useful in templates
All of these can be accessed as {$smarty.const.CONSTANT_NAME}.
| Constant | Meaning |
|---|---|
BLOG_BASEURL | Public base URL of the FlatPress installation |
ADMIN_DIR | Admin directory path relative to the installation root |
PLUGINS_DIR | Plugin directory path relative to the installation root |
THEMES_DIR | Theme directory path relative to fp-interface/ |
FP_INTERFACE | Interface directory |
LANG_DIR | Language directory |
SHARED_TPLS | Absolute path to shared templates |
IMAGES_DIR | Image upload directory |
ATTACHS_DIR | Attachment upload directory |
SYSTEM_VER | FlatPress version string |
RANDOM_HEX | Per-request random token used in some admin templates |
In practice, BLOG_BASEURL is the constant most often used directly in templates.
Template-local helper variables
Some names visible in core templates are not assigned globally by FlatPress.
They are created locally inside the template itself, for example with {assign}, {capture} or {foreach}.
Examples from the default Leggero theme and the admin templates:
| Variable | Where it comes from |
|---|---|
$fp_nextpage | Captured output of {nextpage} |
$fp_prevpage | Captured output of {prevpage} |
$tab / $subtab | Loop variables used by admin navigation templates |
Practical rules
- Use
$flatpressfor normal blog data that should be theme-friendly. - Use
$fp_configwhen you need the full configuration tree, for example locale settings. - Use
$panelstringsin admin templates instead of hard-coded labels. - Use
{$smarty.const.BLOG_BASEURL}when you need a stable base URL in a template. - Do not assume that plugin variables exist unless the plugin is active.
- Do not treat
PLUGINNAMEas a real constant. For plugin templates, use theplugin:resource syntax instead.
Quick examples
Link to the blog root
<a href="{$smarty.const.BLOG_BASEURL}">{$flatpress.title}</a>
Link to an image inside the active theme
<img src="{$flatpress.themeurl}imgs/logo.svg" alt="{$flatpress.title|escape}">
Print the current page title
<title>{$pagetitle}</title>
Show admin panel heading
<h2>{$panelstrings.head}</h2>
<p>{$panelstrings.descr}</p>
