The following entry...
... in the "Form HTML" content of a ChronoForm is causing the following error when I try to save it:
I think the problem is that the file is in
Is there is a JURI::xxx kind of framework function out there that will give me the effective root of the website path so I can then provide a full path instead of the relative path? (Looked, but so far no luck.)
Thanks in advance for any insight.
RELATED QUESTION: Is there a best practice on where to store code snippets that will be loaded by a chronoform via hooks like "Form HTML"? (I have several forms, all using the same snippets and want to avoid repeated copy-paste.)
<?php
require_once("includes/eshp/form/mystuff.php");
?>
... in the "Form HTML" content of a ChronoForm is causing the following error when I try to save it:
Warning: require_once(includes/eshp/form/mystuff.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\MySite\administrator\components\com_chronocontact\admin.chronocontact.php(2736) : eval()'d code on line 2
I think the problem is that the file is in
C:\xampp\htdocs\MySite\includes\eshp\form
but the eval is not going relative toC:\xampp\htdocs\MySite\
. I cannot hardcode the full path (have to keep it relative) because my development environment(s) have different "MySite" names in the path.Is there is a JURI::xxx kind of framework function out there that will give me the effective root of the website path so I can then provide a full path instead of the relative path? (Looked, but so far no luck.)
Thanks in advance for any insight.
RELATED QUESTION: Is there a best practice on where to store code snippets that will be loaded by a chronoform via hooks like "Form HTML"? (I have several forms, all using the same snippets and want to avoid repeated copy-paste.)
Hi joomlanoob,
This is a 'feature' in the current release - ChronoForms tries to evaluate the Form HTML on save to extract an updated list of input names. Unfortunately this breaks when some PHP is included.
The current workaround is to add
Bob
Later: added the missing ()
This is a 'feature' in the current release - ChronoForms tries to evaluate the Form HTML on save to extract an updated list of input names. Unfortunately this breaks when some PHP is included.
The current workaround is to add
if ( !$mainframe->isSite() ) { return; }
just after the <?php tag; this blocks the evaluation in the Admin back-end but allows the require_once to run in the front-end.Bob
Later: added the missing ()
Bob, you spotted the issue right away. However, the code snippet prevents the require_once from running anywhere, not just on the save. For example, I ran this test in the hook...
The "TEST BEFORE" text appears, but the "TEST AFTER" does not appear. Is there another way to keep Chronoforms from trying to evaluate the require_once on the save but still have it run on the front end?
Regards,
Frank
PS - I enabled virtual hosting in my appache, so the variable "MySite" portion of the path should no longer be a factor.
echo "<br>TEST BEFORE";
if ( !$mainframe->isSite ) { return; }
echo "<br>TEST AFTER";
The "TEST BEFORE" text appears, but the "TEST AFTER" does not appear. Is there another way to keep Chronoforms from trying to evaluate the require_once on the save but still have it run on the front end?
Regards,
Frank
PS - I enabled virtual hosting in my appache, so the variable "MySite" portion of the path should no longer be a factor.
Hi Frank,
Apologies, I was in a rush and typed from memory. Please try
Bob
Apologies, I was in a rush and typed from memory. Please try
if ( !$mainframe->isSite() ) { return; }
with added () - I think it's a method, not a variable.Bob
Thanks again Bob, that did the trick! (I should have thought of trying it as a function, the name implied that.😶 )
Regards,
Frank
Regards,
Frank
This topic is locked and no more replies can be posted.