Layout class

At the heart of every web page it the Layout class. Below is the source code for the default index.php file added during installation.

/index.php:

 

You can also assign your layout setup configuration by altering the static variable layout::$config as seen in your file /config/config.static.php. The static variables will be overwritten by local variables defined on each page.

Also, any page can be loaded with the GET variable clearcache equals 1 to empty the cache for the web page being loaded. (E.g. /contact?clearcache=1)

Layout configuration array

Below are all the variables accepted in the layout setup configuration.

Variable/Key
Type
Default
Description
compress
boolean
false
Set to true to enable website compression when completed.
googleAnalytics
array
array(
  "enabled"=>false,
  "id"=>"",
  "domain"=>""
)
configure accordingly for your website. The ID is your Google Analytics tracking ID usually begins "UA" and can be found on the 'Tracking Code' page within your analytics account.
E.g. UA-12345678-9
facebook
array
array(
  "enabled"=>false,
  "appID"=>"",
  "channelURL"=>""
)
configure accordingly if you require facebook integration for Like buttons etc.
facebookPixel
array
array(
  "enabled"=>false,
  "init"=>""
)
configure accordingly for your website. The init key is the variable shown in your facebook pixel integration code shown like this:
 
fbq('init', 'YOUR_INIT_VAR_IS_HERE');
			 
twitter
array
array(
  "enabled"=>false
)
configure accordingly for your website.
cookiesNotice
array
array(
  "enabled"=>false,
  "notice"=>"We use cookies to ensure you get the best possible experience on our website.",
  "button"=>"agree"
)
if you want to show a cookie acceptance notice, enable it here
errors
string
false (bool)
set this variable to show an error banner at the top of your page
notices
string
false (bool)
set this variable to show an notice banner at the top of your page
nohide
boolean
false
set this variable to true to prevent your notice or error banners from automatically hiding themselves after a period of time
coreVersions
array
array(
  "css"=>"4.2",
  "js"=>"4.2"
)
you can update these values to load older versions of the BW Core Javascript and CSS files.
layouts
array
[]
The array KEY is the LAYOUT name, not the file name.
If the LAYOUT name is "about", the FILENAME will be website.top.about.php and website.bottom.about.php - you could create just 1 file to keep the other from your default layout. E.g. if you only had a website.bottom.about.php file, the default website.top.php file would be used instead.

Layout files are in /layouts/*

The array VALUE is another ARRAY of PAGE NAMES (without their .php extension)


array(
  "about"=>array("contact","about")
)
customCacheIDs
array
[]
This is very important for showing up to date content in data driven websites. The BW Core caches compiled files to save time, and responds with 304 headers if the page has not changed since the browser's last request. It cannot detect whether data you've selected in your database has changed or a number of factors such as additional files added within your page at the time of execution instead of having been laoded before.

In these instances you can populate the array with last modified times, or variables so that if they were not the same at the time the file was cached, the BW Core will still know to serve up a new file.
page
string
false
You can override which file to load in from the "pages" folder if required. By default it is the loaded page with "-page.php" appended, e.g. the page for home.php is home-page.php in the "pages" folder
pageOuter
string
false
You can override which file to load in from the "pages" folder if required. By default it is the loaded page with "-page-outer.php" appended (and if the file exists), e.g. the outer page for home.php is home-page-outer.php in the "pages" folder
websiteTop
string
false
You can override the website layout header file loaded in for the top of a page. By default this will be website.top.php OR if configured in the config.php file, there may be a fdifferent file used for a range of pages so you do not need to override them on each individual page. E.g. you may have configured website.top.loggedin.php to be used in the config file. This value will override that as well
websiteBottom
string
false
Use in the same way as websiteTop, but for the bottom/footer of your web page

Head configuration array

Within the layout main configuration is your 'head' key. Below are the accepted variables for this array.

Variable/Key
Type
Default
Description
title
string
Untitled Page
The name of your web page
noIndex
boolean
true
set to false to enable indexing by search engines
canonical
string
false (bool)
you can define your page's canonical URL if it can be reached from multiple URLs
favicon
string
false (bool)
specify the path to your web page's favicon .ico file
viewport
string
""
specify your web page's viewport for mobile devices
css
array
[]
you can specify additional css files to be included in your document's head. (not recommended)
js
array
[]
you can specify additional javascript files to be included in your document's head. (not recommended)
fonts
array
[]
each value can be a:
1. string: path to your font file
2. array:[0]:string:path to your font file, [1]:boolean:whether to include the file contents in your document's head
meta
array
array(
  "ogTitle"=>array(
    "property"=>"og:title",
    "content"=>""
  ),
  "ogDescription"=>array(
    "property"=>"og:description",
    "content"=>""
  ),
  "ogURL"=>array(
    "property"=>"og:url",
    "content"=>""
  ),
  "articlePublished"=>array(
    "property"=>"article:published_time",
    "content"=>""
  ),
  "articleModified"=>array(
    "property"=>"article:modified_time",
    "content"=>""
  ),
  "ogSiteName"=>array(
    "property"=>"og:site_name",
    "content"=>WEBSITE_NAME
  )
)
Some meta data will be automatically populated. You can use the default configuration as a guide on adding your own custom meta tags.

The KEY of each item is not used in the tag unless the VALUE is a string. In this case the VALUE will become the value of the CONTENT attribute in your tag and the KEY will become the PROPERTY attribute.
link
array
[]
This follows the same syntax as your meta variable but for <link /> tags.
telephoneFormatDetect
boolean
false
Set to true to turn on automatic formatting for telephone numbers detected. (Usuall on mobile device browsers)