Forums

Chronoforms style

vecchia 20 Aug, 2009
Hi all,
i need to create a specific chronoforms form with my own style and my own code. Is possible to create a new form and put my own code witouth using the form wizard? If i need to load custom css and javascript from files how i can do it?
GreyHead 20 Aug, 2009
Hi vecchia,

Sure, just enter the code in the Form HTML box.

To add js & css snippets and files the 'Joomla style' structure I use is:
<?php
// near the beginning of the form html
$doc =& JFactory::getDocument();
$script = $style = "";
$script_array = $style_array = array();
$style_array[]  = JURI::base().'components/some_path/some_css_file.css';

$script_array[] = JURI::base().'components/some_path/some_js_file.js';
// repeat for more files
$style .= "
// some css snippet
";
$script .= "
// some javscript snippet
";
?>
. . .
more php & html and more snippets 
. . .
<?php
// at end of form HTML
// load scripts and styles
if ( $script ) {
    // wrap the snippets as a MooTools 'domready' event
    $script = "window.addEvent('domready', function() { $script });";
    $doc->addScriptDeclaration($script);
}
if ( count($script_array) ) {
    foreach ($script_array as $s) {
        $doc->addScript($s);
    }
}
if ( $style ) {
    $doc->addStyleDeclaration($style);
}
if ( count($style_array) ) {
    foreach ($style_array as $s) {
        $doc->addStylesheet($s);
    }
}
?>
This will load all of these files and snippets into the <head> block of the page
This topic is locked and no more replies can be posted.