Hi Bob,
How do you pull in include files into forms built in Joomla and CF in particular?
I have a number of functions that need to be used in many forms and the usual maintenance issues are creeping in. (where common code is used in many forms, maintaining code consistency is a nightmare)
Include files seem to be the obvious solution or does CF have a better one? Also can the include file look like a form, and appear in the backend admin section? if so, how do I call it?
Thanks
aj
How do you pull in include files into forms built in Joomla and CF in particular?
I have a number of functions that need to be used in many forms and the usual maintenance issues are creeping in. (where common code is used in many forms, maintaining code consistency is a nightmare)
Include files seem to be the obvious solution or does CF have a better one? Also can the include file look like a form, and appear in the backend admin section? if so, how do I call it?
Thanks
aj
Hi aj,
I use included files all the time, they are easy to use but not directly suported by ChronoForms (I've asked Max aout this so maybe in the future).
I add an 'includes' folder inside components/com_chronocontact and keep my files in there. If they are specific to one form I keep them in subfolders named after the form (I often include the form HTML or OnSubmit code this way).
To include a file just add code like this into the Form HTML
Joomla also has a concept of helper files. Thes are classes containing static methods for use elsewhere. If you look at the ChronoForms plugin code you'll find that almost all the plugins use a common helper file with a stack of code to create form elements for the configuration dialogues and handle the plugin parameters. You could extend this use in ChronoForms with a little work.
Bob
I use included files all the time, they are easy to use but not directly suported by ChronoForms (I've asked Max aout this so maybe in the future).
I add an 'includes' folder inside components/com_chronocontact and keep my files in there. If they are specific to one form I keep them in subfolders named after the form (I often include the form HTML or OnSubmit code this way).
To include a file just add code like this into the Form HTML
<?php
if ( !$mainframe->isSite() ) { return; }
include(JPATH_SITE.DS.'components'.DS.'com_chronocontact'.DS.'includes'.DS.'form_name'.DS.'filename.php');
?>
(You only need the if() clause in the Form HTML box before you first add php but it does no harm elsewhere.)Joomla also has a concept of helper files. Thes are classes containing static methods for use elsewhere. If you look at the ChronoForms plugin code you'll find that almost all the plugins use a common helper file with a stack of code to create form elements for the configuration dialogues and handle the plugin parameters. You could extend this use in ChronoForms with a little work.
Bob
This topic is locked and no more replies can be posted.