siteConfig - Mura Docs v7.0

siteConfig

A Mura Scope object, (also referred to as a "subscope" of the Mura Scope), that provides access to several helper methods for the Site Settings in the current request context, as well as easy access to its attributes.

Function Syntax

m.siteConfig( property, propertyValue )

Parameters

Parameter Type Req/Opt Default Description
property string Opt  

Optionally pass in an attribute name, and Mura will return its value (unless a propertyValue is also provided). If the property parameter is omitted, Mura will return a site settings object, which has several helper methods associated to it.

propertyValue any Opt  

If you pass in a property, you may optionally "set" the value of the property by passing in a value to this parameter. If you leave this parameter empty, Mura will return the actual value stored in the database for the requested property.

Usage

Use this function to "get" and/or "set" values of the Site Settings. The siteConfig object also has a number of helper methods, very useful for theme developers, and are noted below under the Examples.

Examples

Note: Some of the examples below make use of esapiEncode to encode a given string for safe output to stop Cross Site Scripting attacks.

Site Asset Path

The following example outputs a relative path to where the site files reside on the server.

<cfoutput>
<p>
  #m.siteConfig('assetPath')#
  </p>
</cfoutput>

This is useful for when you may want to create dynamic links to files located under your site. For example, if you want to include Mura's CSS for base styling in your theme, you could use the following code example.

<cfoutput>
  <!--- Mura CMS Base Styles --->
  <link rel="stylesheet" href="#$.siteConfig('assetPath')#/css/mura.7.0.min.css?v=#$.siteConfig('version')#">
  <!--- Mura CMS Skin Styles --->
  <link rel="stylesheet" href="#$.siteConfig('assetPath')#/css/mura.7.0.skin.css?v=#$.siteConfig('version')#">
</cfoutput>

Theme Asset Path

The following example outputs the a relative path to where your site's theme files reside on the server.

<cfoutput>
  <p>
#m.siteConfig('themeAssetPath')#
  </p>
</cfoutput>

This is useful for when you may want to create dynamic links to your theme's CSS files. Otherwise, you would have to hard-code the path yourself, which makes it difficult for long-term maintenance since your theme could be hosted in different environments, and the paths could be completely different. For example, if you want to include your theme's CSS, you could use the following code example.

<cfoutput>
  <!--- Your Theme's Styles --->
  <link rel="stylesheet" href="#$.siteConfig('themeAssetPath')#/css/your-styles.css">
</cfoutput>

Site Name

The following example outputs the "Site Name" of the site being accessed in the current request context.

<cfoutput>
  <header>
<a class="navbar-brand" href="/">
#esapiEncode('html', m.siteConfig('site'))#
</a>
  </header
</cfoutput>

Site Tagline

The following example outputs the "Site Tagline" of the site being accessed in the current request context.

<cfoutput>
  <header>
<p>
#esapiEncode('html', m.siteConfig('tagline'))#
</p>
</header
</cfoutput>

Site ID

The following example outputs the "Site ID" of the site being accessed in the current request context.

<cfoutput>
#esapiEncode('html', m.siteConfig('siteID'))#
</cfoutput>

Domain

The following example outputs the "Domain" of the site being accessed in the current request context.

<cfoutput>
#esapiEncode('html', m.siteConfig('domain'))#
</cfoutput>

Inspecting Available Attributes

This example demonstrates how to inspect the available attributes of the Site Settings. For more information the CFML tag cfdump, please visit https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-d-e/cfdump.html.

<cfdump var="#m.siteConfig().getAllValues()#">