Logo for the Grawlix CMS
Grawlix — The CMS for ComicsDocumentation

The snippet( ) function

Each PHP script in a Grawlix theme is actually part of a given web page. The Grawlix CMS assembles HTML from different parts we call “snippets”. Writing this code:


Will grab the contents of a file called “snippet.header.php” and add it to the overall file. For example, the file called page.comic.php includes a header, a footer, and other snippets.

Technically you could name a snippet anything you want, like snippet.wokkawokka.php as long as it begins with “snippet” and ends with “php”.

Most of the page names are self-explanatory … at least, we think so, but we wrote the thing. So here’s a key:

snippet('name') is a function for including a template file from your install’s filesystem. The text in quotes matches part of a filename. For example, snippet('header') corresponds to snippet.header.php. Likewise snippet('wokkawokka') would grab the “wokkawokka” snippet. That’s just an example, though. It’s not real.

Here are some real snippets that the Grawlix CMS uses:

  • header
  • comic-nav
  • share
  • follow
  • twitterstream
  • transcript
  • comments
  • footer
  • sidebar
  • googleanalytics

These files must use the .php extension, but they don’t have to contain any PHP. Also, you can create your own snippets.