use

Back
Download example 1Run example 1
Run example 2Download example 2
Purpose of this directive is to import first level directives (filters, content, name) from source file in current application. In a way provides the same functionality as include does for php ;

To parse remote files "allow_url_fopen" needs to be set to On in php.ini

Context: direct children of //app

Remarks:
- where attribute allows to place the imported source into a specific tree location by creating nodes as indicated; If you specify /client/header, use directive will create a new document element header, which will be appended to a new element client, which will replace the directive itself;
- source attribute is mandatory and is the path to a xml file;
- xpath attribute is mandatory
- if use/check is given, the document processor will build a function from the text content of the check node and will import the source or not, depending on the result of the function (function needs to return a value); the goal of this check is to add a condition to use directive. One thing you can do with it is to build browser oriented applications
Picture bellow shows how app processor will import //app/client/header element from templates/index.xml, append to a new 'client' element, which will replace the use directive. You can also see that the client element of the application only has the content, so result of use directive will be to import the header from another application. The difference between use and any import type directive is that 'use' is designed to import top level directives (like client, client/content/, client/header/, filters/..., parsers, etc.);