If you're customising your website templates you'll encounter Capitan PHP snippets in the HTML code. In this article we'll list all of the available snippets and explain what they do... Note that these PHP snippets can only be used in your root templates, they won't work within page content.
PHP Intro
A PHP snippet must start with an opening tag:
<?php
And end with a closing tag:
?>
The PHP instruction (known as a function) is written between these tags. In Capitan we've restricted the use of some functions, the only one youneed to know about is 'echo' which basically translates to 'insert something into the page right here':
<?php echo 'hello'; ?>
This prints the word 'hello' wherever you put the PHP snippet on the page.
The Capitan framework prepares a number of snippets of dynamic content whenever a page is loaded - some of these contain data specific to the page, others contain data which is specific to your installation profile. They're all saved as variables with relevant names which you can easily insert into your HTML template or content as required:
<?php echo $CAP_COMPANY_NAME; ?>
The variable name is $CAP_COMPANY_NAME
The Company Profile owning this installation has the 'Company Name' Capitan
Therefore this example would print 'Capitan' in the page.
Page Specific PHP Variables
Containing dynamic data specific to Standard Pages, Module categories and Module Items.
- $CAP_ITEM_TITLE
The title of the page coming from the page's 'SEO Title' - $CAP_ITEM_DESCRIPTION
The description of the page coming from the page's 'SEO Description' - $CAP_ITEM_KEYWORDS
The keywords for the page coming from the page's 'SEO Phrases & Keywords' - $CAP_ITEM_ROBOTS
Data for Meta Tag "robots", ie: 'index, follow'. Based on the page's 'Included in Sitemap' setting and public availability. - $CAP_OG_EXTRAS
Additional Open Graph Meta Tags for the page. Automatically adjusted for certian types of Module Item. - $CAP_ITEM_URL
The canonical URL for the item. Automatically generated based on the page's 'URL' and it's location in the website hierarchy. - $CAP_ITEM_CSS
The path to the CSS resource. Defaults to /css/template.css but can be overriden by the page's 'Custom CSS Template' setting in the 'Design' Tab. - $CAP_ITEM_FILES
The content from 'Required Files' in the 'Advanced' Tab on the page. - $CAP_ITEM_JS
The content from 'Additional Javascript Code' in the 'Advanced' Tab on the page. - $CAP_ITEM_MASTHEAD
The fully rendered content of the 'Masthead' configured in the 'Design' Tab on the page. - $CAP_ITEM_WZ1, $CAP_ITEM_WZ2, $CAP_ITEM_WZ3, $CAP_ITEM_WZ4
The fully rendered content of Widget Zone 1-4 as configured in the 'Design' Tab on the page. - $CAP_ITEM_CONTENT
The fully rendered content of Main Content as configured in the main 'Content Editor' on the page.
Owner Specific PHP Variables
Containing dynamic data specific to the Website Owner Company Profile.
- $CAP_COMPANY_NAME
The Company Name defined in the 'Website Owner' Company Profile - $CAP_COMPANY_ADDRESS1, $CAP_COMPANY_ADDRESS2, $CAP_COMPANY_CITY, $CAP_COMPANY_REGION, $CAP_COMPANY_COUNTRY, $CAP_COMPANY_POSTCODE
Elements of the Primary Address defined in the 'Website Owner' Company Profile - $CAP_COMPANY_WEBSITE
The Website Address defined in the 'Website Owner' Company Profile - $CAP_COMPANY_TEL
The Telephone defined in the 'Website Owner' Company Profile - $CAP_COMPANY_TAX
The Tax Number defined in the 'Website Owner' Company Profile - $CAP_COMPANY_REG
The Company Number defined in the 'Website Owner' Company Profile - $CAP_COMPANY_META / $CAP_COMPANY_FACEBOOK, $CAP_COMPANY_X / $CAP_COMPANY_TWITTER, $CAP_COMPANY_INSTAGRAM, $CAP_COMPANY_LINKEDIN
The Profile ID for the relevant Social Media channel defined in the 'Extended Profile' Tab of the 'Website Owner' Company Profile
General Utility PHP Variables
- $CAP_JS_CORE
Javascript dependancies required for the correct rendering of your web pages. Do not remove. - $CAP_TOOLS_BODYCLASS
The CSS Smart Wrapper for the rendered page. Do not remove. - $CAP_TOOLS_OPENINGTAGS
Containing some modal blocks and pre-loaders which are required for the correct running of your web pages. Do not remove. - $CAP_TOOLS_BREADCRUMBS
Outputs a breadcrumb trail explaining the location of the rendered page in the navigation hierarchy - each crumb acts as a link. - $CAP_TOOLS_ACCESSKEYS
Outputs a hidden list of your Access Key content (if you've used this accessibility feature) and enabling the functioning of these access keys. - $CAP_TOOLS_SEOSUMMARY
Outputs a hidden SEO summary of the rendered content. - $CAP_CONSENTMODE
Outputs the status of the visitor's consent to essential cookies, the value is either 'granted' or 'denied'. - $CAP_ADV_CONSENTMODE
Outputs the status of the visitor's consent to non-essential cookies, the value is either 'granted' or 'denied'.
Dynamic Navigation PHP Function
Outputs a dynamically generated navigation menu including the relevant styling of the currently active page or section:
The function name is $FE_CORE->navTree()
The function requires four variables to be defined, in the specified order:
<?php echo $FE_CORE->navtree(PARENT, SUBNAV LEVELS, EXTRA DATA, EFFECTS); ?>
- PARENT
Used to define the absolute top level to be output in the navigation. Valid values are:
String 'nav' - the top level main pages
String 'float' - the top level floating pages
Integer 'Capitan CID' - the CID of the Capitan page to be used as the top level - SUBNAV LEVELS
Used to define how many sub-levels of navigation should be output, if any of the items have 'children'. Valiud value is an Integer. - EXTRA DATA
Used to define additional data being rendered in the navigation. It's possible to include an image, preview text and a button for every item in the menu. Valid value is a String of 3 Booleans which are separated by pipe bars, ie: 'true|false|false'. The first boolean is for ICON which allows you to include the item's 'Cover Image' in the output. The second boolean is for PREVIEW which allows you to include the item's 'SEO Description' in the output. The final boolean is BUTTON which allows you to include a styled button as the navigation link in the output. Using this setting along with some custom CSS definitions can help you build a mega-menus. - EFFECTS
Used to define some visual and behavioural effects in the rendered navigation. control some built in effectspopup link and sub-nav transition options. Valid value is a String of 2 settings which are separated by pipe bars, ie: 'setting1|setting2'. The first setting is POPUP and expects a boolean for pop-up link activation. The second is CLASSES and expects a string of CSS class names which will be added to the rendered navigation, commonly used to activate navigation transition effects.
A full example would be:
<?php echo $FE_CORE->navTree('nav',2,'','false|animated fadeIn'); ?>
The rendered navigation parent is 'nav' which is your top page navigation level, it permits 2 levels of sub navigation if any of the pages have children, it has no extra data so only the page titles will be output, and is defines effects false|animated fadeIn which means pop-up links are disabled and 'animated fadeIn' classes are added to the rendered navigation