Welcome, Guest
Username: Password: Remember me
This category is read only
  • Page:
  • 1

TOPIC: Using PHP in JooDB templates

Using PHP in JooDB templates 7 years 6 months ago #1566

  • Dirk
  • Dirk's Avatar Topic Author
  • Offline
  • Posts: 1112
  • Karma: 21
  • Thank you received: 202
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>
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.

Last edit: by Dirk.
  • Page:
  • 1