General
Getting Support
Administration
Design
Wolf Reference
Plugin Development
Core Development
- Design documents
- Working guidelines
- References
Press, Graphics and Translations
Wolf CMS books section
includeSnippet()
This function is used to include "snippets" in Wolf pages. The syntax is:
<?php $this->includeSnippet('the_name_of_the_snippet'); ?>
On the way the special PHP variable $this-> behaves when used in a snippet, see the documentation for $this->.
Snippets may call/include other snippets.
From 0.7.0:1) the includeSnippet() function will return “true” if the snippet name is found, but “false” if the snippet name does not exist. If a test is used which evaluates includeSnippet() as “true”, the value of the snippet will be passed automatically.
Hints
Conditional Use of Snippets
You could also create a snippet with your php code, then only include it on the relevant page by using a conditional statement. That way you won't need a page-part, and it's only a small addition to your layout:
<?php // only include on contact page or children if(url_start_with('/contact')) $this->includeSnippet('the_name_of_the_snippet'); ?>
Just keep in mind that it will also be included in any children pages, because it's looking for a url that begins with the provided text.
