Forums

include php file

dench 06 Jan, 2018
Hi and happy new year to all !

I am a joomla user of chronoforms V4, I already have found how to include JS scripts inside the code of my forms, for example :
..................
<?php
$doc =& JFactory::getDocument();
$doc->addScript('https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js');
$doc->addScript('/dench/Chronoforms/JS/shooting_test.js');
$doc->addScript('/dench/Chronoforms/ionSound/ion.sound.js');
echo nextend_smartslider3(8);
?>
......... and then the code...........


You can see that my JS_File (shooting_test.js) is in a folder inside my root, that is very useful when I decide to edit my JS script without opening chronoforms

But I did not find how to include PHP files the same way...

Here is an example of code that I use in the events of a form for sending an email to someone after a submit button :
( The php section is to check wether the customer do have a valid coupon code )
......................
<?php
$source = file_get_contents('http://www.xxx.com/Offers.json');
$data = json_decode($source, true);
$code_coupon=$_POST['Codexxx'];
$valeur=$data[$code_coupon];
$reduction=((1-$valeur)*100).'%';
$TotalCommande=$_POST['TotalCommande'];
if (array_key_exists($code_coupon, $data)) {
$prixEffectif=$TotalCommande*$valeur;
$prixEffectifTexte=number_format(($prixEffectif), 2)." €";
} else {
$reduction='code_erroné';
$prixEffectif=$TotalCommande*1;
$prixEffectifTexte=number_format(($TotalCommande), 2)." €";
}
?>
<h2 style="text-align: left; font-family:Sniglet,tahoma; font-size:12px;font-weight:bold;">
Hello <span style="color: #B99676;">{Prenom}</span>, <br />
Ceci est ton <span style="color: #BB1D56;">Bon de Réservation </span> pour la Séance-Photo que nous avons prévue pour le <span style="color: #BB1D56;">{Date1}</span> à <span style="color: #BB1D56;">{Heure1}</span><br />
.................


So, you surely understand that I would love to have something like :
$doc->addScript('/DenchPlugins/Chronoforms/PHP/shooting_test.php');

Do you think this is possible ?

Thank you very much by advance for your response and please forgive me for my english ☺
Dennis
GreyHead 15 Jan, 2018
Hi Dennis,

You can include a PHP file from a Custom Code action (and some others). Here is the code I used for CFv4
<?php
include (JPATH_SITE.'/components/com_chronoforms/includes/'.$form->form_details->name.'/file_name.php');
?>
You can change the file path to suit your needs.

Bob
This topic is locked and no more replies can be posted.