-1

I have install DirectPHP and it works fine, I can actually print out the current time with PHP, so I know it works.

My problem lies in using a custom PHP to call out variables and print out in all my articles.

First: My custom php inside /media/custom.php

<?php
// Rental Prices Equipment
$miniraeClassic_d = "$35.00";
$miniraeClassic_m = "$120.00";
$miniraeClassic_y = "$400.00";

$message = "Hello World";
?>

Second: Here is where I included the PHP file I want to retrieve information from. This was included in the index.php of my template.

// Preparing template parameters
JSNTplTemplateHelper::prepare();

// Get template utilities
$jsnutils = JSNTplUtils::getInstance();
?>
<?php
include '/media/custom.php';
?>
<!DOCTYPE html>
<!-- <?php echo $this->template . ' ' . JSNTplHelper::getTemplateVersion($this->template); ?> -->
<html lang="<?php echo $this->language ?>" dir="<?php echo $this->direction; ?>">
<head>

Third: In my article I added two codes, one trying to retrieve $message from my custom.php, and another to test if PHP actually works in my article (which prints out the time).

<?php
echo $message;
?>

Now is: <?php echo date('Y-m-d H:i:s');?>

enter image description here

Fourth: here is the result, in my article, it does not print out $message, but it does print out the date and time.

It did not print out $message
in my article, the only thing it printed out was

Now is: 2014-05-28 22:21:50 

enter image description here

I want to call out multiple variable around my article i.e.

<table border="0" width="100%">
<tr>
<td width="32%" align="center" class="table-title"><b>Daily</b></td>
<td width="34%" align="center" class="table-title"><b>Weekly</b></td>
<td width="34%" align="center" class="table-title"><b>Monthly</b></td>
</tr>
<tr>
<td align="center" class="table-content"><?= $dayrental?></td>
<td align="center" class="table-content"><?= $weekrental?></td>
<td align="center" class="table-content"><?= $monthrental?></td>
</tr>
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103

1 Answers1

0

Try using the following to import your custom php file:

<?php
    include(JUri::root() . 'templates/' . $this->template . '/media/custom.php');
?>

JUri::root() defined the root of your Joomla installation which you have not defined in your code.

Lodder
  • 19,758
  • 10
  • 59
  • 100
  • i tried that right now, changed it to template . '/custom.php'); ?> and added the custom php where my template index.php resides and still no "hello world" message in my article. – RealPetChicken Jun 02 '14 at 19:53
  • however, i added to my custom php `code`MY MY MY";`code` and i checked my article source code and found `code` `code` – RealPetChicken Jun 02 '14 at 20:07