Assuming we want to include an external script called myscript.php
There are currently the following possibilities (assuming you did install Moslate already), choose the one you prefer...
Include external scripts |
A - use scriptletIn the first version we do this by using the {scriptlet}-tag... 1) Import the samples_export 2) Edit a content-item (assuming default configuration) and write:
B - use jsp:includeThis time we go for a cleaner way by using jsp:include (defined by the JSTL) 1) Import logic_export 2) Edit a content-item (assuming default configuration) and write:
C - use c:importThis is similiar to jsp:include, but it allows an URL instead. It is also possible to redirect the output to a Logic variable. 1) Import logic_export 2) Edit a content-item (assuming default configuration) and write:
D - create moslate (mode:Eval as PHP)This time we reduce the code inside the content item: 1) Go to Moslate Categories and create a Category (or skip this and use an existing) 2) Go to Manage Moslate and click on New 3) For the name you may choose: includemyscript 4) In your template code write:
6) For mode choose: Eval as PHP 7) Edit the content item and write:
This also demonstrates how to pass optional parameters to your newly created Moslates. Those parameters will be automatically available as local function variables (they are not global). E - create moslate (mode:Include PHP)This is very similiar to the above but uses another mode to include the script: 1) Go to Moslate Categories and create a Category (or skip this and use an existing) 2) Go to Manage Moslate and click on New 3) For the name you may choose: includemyscript2 4) In your template code write: /pathtomambo/myscript.php5) Click on the Parameters-tab (the most to the right) 6) For mode choose: Include PHP 7) Edit the content item and write:
In this example an absolute path is used. If the path is relative, it will be relative to /components/com_moslate/templates. |