Light-weight, fast, simple and powerful!
Translations of this page?:


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.


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.

HT: mrgoatee

1) Added to core at Revision 172.
functions/includesnippet.txt · Last modified: 2011-09-12 00:46 (external edit)
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 / design by yello studio / Wolf CMS Inside