× This category is read only

Using PHP in JooDB templates

More
11 years 2 months ago - 11 years 2 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.
<?php
  $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
How_to_override_the_output_from_the_Joomlacore

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

Example
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};
</script>
Last edit: 11 years 2 months ago by Dirk.
The following user(s) said Thank You: rammon, MichaS., office.terraristik, jumagaru

Please Log in to join the conversation.