Another function which is extremely important within SPIP, recuperer_fond()
, is used to return the results of compiling a given template. This is sort of the same as for <INCLURE{fond=name} />
used in templates but in PHP.
It accepts from 1 to 4 parameters:
- the name and address of the source code file (without extension)
- the compilation context (key/value table)
- a table of options
- the name of the connection file for the database to be used
Simple usage
The data returned is the code generated by the compilation output:
$code = recuperer_fond($name, $context);
Advanced usage
The raw
option set to true
will provide, rather than just the generated code, a table of items calculated by the compilation, which also includes the code (with the key texte
).
What does this table contain then? The text, the address of the template source (tagged "source"), the filename of the PHP cache generated by the compilation (tagged "squelette"), an indicator of the presence of PHP in the generated cache file (tagged "process_ins"), and various other values included in the compilation context (the language and data are automatically added since they have not been passed as parameters).