PHP Classes

File: snippets.txt

Recommend this page to a friend!
  Classes of Mark Cole   PHP Online Help System   snippets.txt   Download  
File: snippets.txt
Role: Auxiliary data
Content type: text/plain
Description: Snippets file (part of example)
Class: PHP Online Help System
Get site help topics from file defined with macros
Author: By
Last change:
Date: 9 years ago
Size: 2,573 bytes
 

Contents

Class file image Download
# This is the snippets file. Snippets are small blocks of text that are used in more than one place # so making them into snippets means that you don't have to repeat the same text over and over # To include a snippet put it into your text as $snippet:snippet_name eg: $snippet(mysnippet). # Each snippet in this file starts with :snippet_name and ends either at the next snippet or at eof. # # Snippet names are case-sensitive. # # Snippets can include all macros and can include other snippets (ie. nested) but beware # of infinite loops ie. a snippet that contains itself, or eg. snippet 1 references snippet 2 which references # snippet 1!. There is no check for this so you will only find out when your help page hangs in a loop. # Help.php takes a ":" as the first character of a line to be the start of a snippet and thus the end of the # previous snippet so you can use a single ":" to separate snippets in this file for readability. # # the include/includerole directives are valid in a snippets file # :copyright <p style="text-align: center; font-size:8pt; font-weight:bold;"> All content Copyright 2014 the foo organisation. </p> :varsubexample Example Variable Substitution \t<strong>The variable \$example says: $example</strong> :macroerrors <p> Assuming that the variable @{variables:phphelp->ignoreErrors} is set false (the default) then when an error occurs while PHPHelp is interpreting a macro (and here I mean a syntax error in the macros arguments) you will see an error message displayed in place of the help topic you were expecting. The error message will tell you the nature of the error and the file and line where it occurred. It is important to note that macros in a line are interpreted right to left so that if you have more than one error you will see what you would expect to be the last one first. The syntax errors detected by PHPHelp for @{usermacros:user-defined} macros are limited to such things as missing quotes, commas or closing brackets.\b\b \@macro(bad arg") will produce this error: <strong>expected "," or closing ")"</strong>\b\b whereas\b\b \@macro(badarg") will be accepted as one argument, the string <strong>badarg"</strong>\b\b This is because the first example is seen as one argument - "bad" and PHPHelp will expect that it will be followed either by a comma and another argument OR by a closing bracket.\b\b The simplistic method of parsing used by PHPHelp can lead to odd errors if you ask too much of it.\b\b The best bet is simply to wrap all arguments in quotes. </p>