Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

We use Twig as our default template engine. If you haven't worked with Twig or the Liquid Templating language, make sure to read up on how Twig works here.

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.

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

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

<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.
{% if is_user() %}
Hello User!
{% endif %}
true on success, false on failure.
is_admin()Checks to see if a user is an admin.
{% 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.
<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.
<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. 
{{ _p('Hello World') }}
Returns the phrase passed to the function
if the translation does not exist. Otherwise
it returns the translated version. 
asset(string $image)

 


$image

Relative path to image in your themes assets/ folder.

Include images in your themes.
// Will return full URL to image in your themes assets/ folder
<img src="{{ asset('foo.png') }}">
 
// Will return full URL to image in your themes assets/image/ folder
<img src="{{ asset('image/foo.png') }}">
 
URL of image.
  • No labels