Template Variables
Every view in Kickflip will be rendered with a few kinds of variables available to it. The primary variable types are:
- Site Variables,
- Page Data, and
- any Global Shared Data.
Global Shared Data¶
Adding data that will be accessible to all views is super easy. This is mainly because Laravel's Blademakes this really easy. And because Kickflip uses the same provider for Blade as Laravel things work very similar.
In Kickflip, this is done simply by using View::share('key', 'value')
just like in Laravel. The proper place to add these into would be in your sites config/bootstrap.php
file.
For example, Kickflip itself loads the SiteData::class
instance using:
View::share(
'site',
SiteData::fromConfig(KickflipHelper::config('site', []), KickflipHelper::config('siteNav', []))
);
This bootstrap config file will be loaded in at the very end of Kickflip's KickflipServiceProvider::boot()
method. Read more about this idea directly on the Laravel Docs under Sharing Data With All Views.