-
Notifications
You must be signed in to change notification settings - Fork 72
Facade Reference
The Caffeinated Themes package comes with a handy Facade to make calling and loading theme pages easy within your code.
Themes
Theme::all()
Theme::getActive()
Theme::setActive($theme)
Theme::view($view, $data)
Theme::response($view, $data, $status, $headers)
Components
Get all themes.
Collection
$themes = Theme::all();
Returns the currently active theme.
string
$activeTheme = Theme::getActive();
Sets the active theme that will be used to retrieve view files from.
(In Laravel 5.4+ use setCurrent)
-
$theme
(string) Theme slug. Required
null
Theme::setActive('bootstrap-theme');
Renders the defined view. This will first check if the currently active theme has the requested view file; if not, it will fallback to loading the view file from the default view directory supplied by Laravel.
-
$view
(string) Relative path to view file. Required -
$data
(mixed) Any additional data you'd like to pass along to the view file to be displayed.
View
$foo = 'bar';
return Theme::view('welcome', compact('foo'));
Rendered the defined view in the same manner that Theme::view()
does, but allows the means to set a custom status response and header for the rendered page.
-
$view
(string) Relative path to view file. Required -
$data
(mixed) Any additional data you'd like to pass along to the view file to be displayed. -
$status
(integer) HTTP status code. -
$header
(array) HTTP headers.
Response
$posts = Post::orderBy('published', 'desc')->get();
return Theme::response('blog.rss', compact('posts'), 200, [
'Content-Type' => 'application/atom+xml; charset=UTF-8'
]);
Register a new theme component. This will automatically register custom tags for both Blade and Twig (depending on which you are using), using the convention of component_$name
.
-
$name
(string) The name you wish to give your theme component. Required -
$callback
(mixed) A callback method returning the desired data needed. Required
mixed
Component::register('pageheader', function($title, $subtext) {
return "<h1>{$title} <small>{$subtext}</small></h1>";
});