× This category is read only

Using PHP in JooDB templates

9 years 6 months ago - 9 years 6 months ago #1566 by Dirk
Using PHP in JooDB templates was created by Dirk
A simple template engine can not fit for every requirement. If you want to output calculations you need to extend template output. There are multiple ways to do this.

1) Use a php content-plugin
We tested directPHP . Before you can use this, you make sure that your editor or jommla does not kill the PHP-code from the template. You should also be aware that such a plugin might be a security problem if your site has a public forum for example.

2) Use the plugin system (Pro only)
The pro version has a simple built in plugin system. Just create a php-file with the name of the desired command and add your output $output - variable. (see examples)

Example calculate.php
Multiply ammount with value and send it to the output.
  $output .= "Total: ".number_format(($item->ammount*$item->value), 2, ',', '');
You can now call the plugin by {joodb calculate} in your template.

3) Modify the view output
See here

Use Javascript
If you want to hide fields or modfiy the output you can also use Javascript.

Replace the text in element wit ID calculate with the total.
<script type="text/javascript" >
document.getElementById("calculate").innerHTML = {joodb field|ammount}*{joodb field|value};
Last edit: 9 years 6 months ago by Dirk.
The following user(s) said Thank You: rammon, MichaS., office.terraristik, jumagaru, jrg.san.martin.gmail

Please Log in or Create an account to join the conversation.