Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In addition to the variables and functions supported by Twig, we have a few custom variables/functions for you to work with.

Variables

Variables are needed to fill out your template with dynamic data that is provided by phpFox. These are things from the main content, side panels and the sites title.

 

VariableDescriptionRequiredVersion Added
{{ content }}Displays the main content for the site. This content changes each time a new page is loaded.yes4.0
{{ left }}Primary side block. Loads blocks 1 & 9.yes4.0
{{ right }}Secondary side block. Loads blocks 3 & 10yes4.0
{{ js }}Loads all Javascript files at the footer. This must be placed before the </body> closing tag.yes4.0
{{ title }}Displays the site title. Must be placed inside the HTML <title></title> elements.yes4.0
{{ header }}Loads everything that is to be placed within <head></head>.yes4.0
{{ html }}

Loads the directional and language settings for the site. Must be placed inside the <html> element.

Code Block
<html {{ html }}>
yes4.0
{{ body }}

Loads the pages ID and Class names. Must be placed inside the <body> element.

Code Block
<body {{ body }}>
yes4.0
{{ sticky_bar }}

Loads the notification panel for when a user is logged in.

yes4.0
{{ location_11 }}

This loads block 11 and is where the main header for a user profile is loaded. Its intended to
be above the main content and panels. 

yes4.0
{{ breadcrumb }}Loads the sites breadcrumb, which include section titles and <h1></h1> tags for when viewing an item.yes4.0
{{ main_top }}Some sections support internal searching of that section. This loads the main search routine for these sections.yes4.0
{{ errors }}Displays any errors to the end user. This is usually placed above {{ content }}.yes4.0
{{ logo }}Loads the sites logo and allows Admins to change it directly from the AdminCP.yes4.0

 

Functions

Functions allow you to apply conditional statements to templates and access objects passed along by phpFox.

NameDescriptionUsageReturns
is_user()Checks to see if a user is logged in or not.
Code Block
{% if is_user() %}
Hello User!
{% endif %}
true on success, false on failure.
is_admin()Checks to see if a user is an admin.
Code Block
{% if is_admin() %}
Hello User!
{% endif %}
true on success, false on failure.

permalink(string $route, int $id, string $title)

 


$route

URL path for your link.


$id

Unique ID number.


 

$title

Title of the item

 

 

Creates a permalink. This is an identical function provided
by our PHP permalink() function. This is handy when you want to create an
App that requires viewing an item, like a blog or video. This function follows
our default permalink rules and structure.
Code Block
<a href="{{ permalink('/foo', 1, 'Hello World') }}">Hello World</a>
Parsed permalink.

url(string $route)

 


$route

Route for your link.

Creates a link based on the route provided.
Code Block
<a href="{{ url('/foo') }}">Foo</a>
Parsed URL.

_p(string $phrase)

 


$phrase

Phrase to parse.

If your theme has any phrases or words you can wrap them in this function.
It will automatically create a phrase for Admins in case they wish to
translate your theme. 
Code Block
{{ _p('Hello World') }}
Returns the phrase passed to the function
if the translation does not exist. Otherwise
it returns the translated version.