FusionCMS is currently in an open beta state and under heavy active development.

Helpers

FusionCMS includes a variety of global "helper" PHP functions. Many of these functions are used by the core itself; however, you are free to use them in your own themes and modules.

There are a number of utility helper functions packaged with Laravel that may be used in your own application or theme on FusionCMS. In addition, FusionCMS comes with a number of it's own helper functions to help streamline development.

Available Methods

App

DateTime

Fields

Forms

Menus

Paths

Settings

Strings

Themes


App

app_installed

Use to determine if the CMS is currently installed or not. Returns a boolean value.

app_memory_usage

Returns the memory usage in a human readable format.

app_loading_time

Returns the total loading time in human readable format.

fusion

Returns an instance of the dispatcher class. Used to perform API requests internally.

glide

Returns glide instance of image file, taking optional disk as an argument.

running_in_console

Returns if the current process is running in the console or not.

DateTime

carbon

Returns a new carbon instance.

carbon_date

Returns a new carbon instance, with the timezone and date format pre-configured based on the settings in the CMS.

carbon_time

Returns a new carbon instance, with the timezone and time format pre-configured based on the settings in the CMS.

Fields

fieldtypes

Returns Fusion\Fieldtypes\Registry containing all registered Fieldtype resources.

Forms

render_form

Renders a Form using the form's template or user-specified one:

// Renders form with form's own template.
render_form('contact-us');  

// Renders form with user-specified template.
render_form('contact-us', 'forms.custom-template');

// Renders form, sending additional parameters to form template.
render_form('contact-us', null, ['time' => time()]);

honeypot_fields

Generates and renders Honeypot fields to add to your form for spam prevention. When a form is submitted, these fields will be validated along with the rest of the form.

Menus

menus

Returns Illuminate\Support\Collection of navigation links from requested Navigation.

Paths

fusion_path

The fusion_path function returns the fully qualified path to the fusion package directory. You may also use the fusion_path function to generate a fully qualified path to a file relative to the fusion package directory:

$path = fusion_path();
// /path/to/fusion/settings

$path = fusion_path('settings');
// /path/to/fusion/settings

theme_path

The theme_path function returns the fully qualified path to the fusion/themes directory. You may also use the theme_path function to generate a fully qualified path to a file relative to the fusion/themes package directory:

$path = theme_path();
// /path/to/fusion/themes

$path = theme_path('settings');
// /path/to/fusion/themes/settings

Settings

setting

Access FusionCMS Settings to retrieve or manipulate a setting value at runtime:

// request all settings
setting();

// request setting by key
setting('api.personal_access_token');

// sets runtime setting value by key
setting(['api.personal_access_token' => 'new_value']);

Strings

render_markdown

Converts Markdown to HTML using Parsedown Extra.

render_markdown('
# FusionCMS
Build something special!
')

// <h1>FusionCMS</h1>
// <p>Build something special!</p>

str_handle

Shortcut for:

use Illuminate\Support\Str;

Str::slug($value, '_');

Themes

javascript

Transforms PHP variables into JavaScript.

theme

Return values directly from the theme.json manifest file. You may find detailed breakdown of this helper under theme documentation

{{ theme('name') }}

theme_mix

Use in combination with Laravel Mix to return hashed file values for compiled JS and CSS. You may find detailed breakdowns of these helpers under theme documentation

<script src="{{ theme_mix('js/theme.js') }}></script>

theme_option

Returns either the default or saved value of a specific theme option.

{{ theme_option('colors.primary') }}

theme_preview

Returns as either true or false, indicating if the theme is being viewed through the theme customizer or content preview window.

Have questions?

We're always happy to help with code or other questions you might have. Contact support or chat live with us on Discord.

Last edited on Tuesday, March 30, 2021 (3 years ago)