remotetemplate

Back
  • remotetemplate [source],[cache],[cachestorage],[clearcache] Since AWS XMS 1.1
    • check ($doc,$el) Since AWS XMS 1.1
    • filter ($doc,$el) Since AWS XMS 1.1
    • runfirst ($el) Since AWS XMS 1.1

  • Download example 1Run example 1
    Run example 2Download example 2
    This directive will load a remote web page, convert it to XMS format and adds the result to your application as client tree (html-> client, head->header, body->content). Using Filters you can modify it to suit your need. Cache (or local storage) can be used as well to improve performance.

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

    Context: //app/remotetemplate

    Remarks:
    - the source html document has to be valid (no missing tags) and comply with w3c rules;
    - remotetemplate/runfirst is the first function to be executed, and is mainly used to change the attributes of import directive (xpath, source, importashtml,cache,...). If present, the document processor will create a lambda function from first processing instruction child of the runfirst node and execute it with $el parameter as the DOMNode of parent advancedimport directive
    - if remotetemplate/check is given, the document processor will create a lambda function from first processing instruction child of the check node and import the new element or not, depending on the result of the function (function needs to return a value);
    - if remotetemplate/filter is given, the document processor will build a function from the text content of the filter node and this function will be called with $doc parameter, awsHTML instance on the local/remote file;
    CACHING:

    This basic cache system will store the remote resource only, for increased performance. To enable it you must set directive's cache attribute to "enable".

    Other attributes to set:
    - cachestorage - you must specify the name of the file (mandatory);
    - clearcache number of seconds to wait before update the data source; if set to "FALSE" will store the data source content and never update it later; if set to "0" (zero) will update the data source each time directive is executed;
    Parameters setup; source can be either local or remote file;
    Filters setup
    Check setup
    runfirst child directive setup