Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

ChronoForms 3.1 for Joomla! site Cookbook
ChronoForms 3.1 for Joomla! site Cookbook
ChronoForms 3.1 for Joomla! site Cookbook
Ebook882 pages5 hours

ChronoForms 3.1 for Joomla! site Cookbook

Rating: 0 out of 5 stars

()

Read preview

About this ebook

This book is the missing manual for creating forms on your Joomla! site. Using simple examples that you can easily follow we will show you how you can create forms of almost any kind. Most of the chapters focus on one topic starting with simple recipes for new users and then adding new features that add more to the form but may also require more knowledge and experience to implement.Other chapters look in more detail at adding special features, or creating forms to perform particular tasks. Again the recipes range from those that a new user can easily implement to those that will help more advanced developers.Each recipe is kept as simple as possible and set out so that it can be easily implemented with the code supplied; and the recipes are also a set of building blocks that you can use to create much more complex forms using several recipes to build your form.As far as space allows we have explained how the code works, what features of Joomla or of ChronoForms we are using and we’ve offered suggestions in the ‘There’s more . . .’ sections for ways in which the basic recipe can be extended or adapted.The code examples are complete and can be adapted by new users with the minimum of customization or they can be as a starting point for developers with more coding experience to build on and adapt to create fully customized form applications. This is a practical hands-on book for people who want to add forms to their Joomla! site. Whether you just want to add a simple newsletter sign-up form or a complex multi-page interactive form you’ll find helpful suggestions and recipes that will get your forms working.
LanguageEnglish
Release dateAug 24, 2010
ISBN9781849510639
ChronoForms 3.1 for Joomla! site Cookbook

Related to ChronoForms 3.1 for Joomla! site Cookbook

Related ebooks

Information Technology For You

View More

Related articles

Reviews for ChronoForms 3.1 for Joomla! site Cookbook

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    ChronoForms 3.1 for Joomla! site Cookbook - Bob Janes

    Table of Contents

    ChronoForms 3.1 for Joomla! Site Cookbook

    Credits

    About the Author

    About the Reviewer

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Errata

    Piracy

    Questions

    1. Creating a Simple Form

    Introduction

    Downloading and installing ChronoForms

    Getting ready

    How to do it...

    There's more...

    See also

    Creating a simple form with the Form Wizard

    Getting ready

    How to do it...

    How it works...

    Sending the form results by e-mail

    Getting ready

    How to do it...

    How it works...

    See also

    Showing a Thank You page

    Getting ready

    How to do it...

    How it works...

    There's more...

    Editing your form with the Wizard Edit

    Getting ready

    How to do it...

    How it works...

    Redirecting the user to another page

    Getting ready

    How to do it...

    There's more...

    See also

    Backing up and restoring your forms

    Getting ready

    How to do it...

    There's more...

    2. E-mailing Form Results

    Introduction

    Replying to e-mails

    Getting ready

    How to do it...

    See also

    Getting your e-mails delivered safely

    How to do it...

    How it works...

    Sending a Thank you e-mail to the form submitter

    How to do it...

    Choosing e-mail addresses from a list

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Attaching uploaded files to the e-mail

    Getting ready

    How to do it...

    See also

    Attaching a standard file to the e-mail

    Getting ready

    How to do it...

    How it works...

    Creating a dynamic subject line using info from the form

    Getting ready

    How to do it...

    How it works...

    3. Styling your Form

    Introduction

    Using ChronoForms default style

    Getting ready

    How to do it...

    See also

    Switching styles with Transform Form

    Getting ready

    How to do it...

    How it works...

    See also

    Adding your own CSS styling

    Getting ready

    How to do it...

    There's more...

    Browser sniffing

    Conditional CSS

    Putting several inputs in one line

    Getting ready

    How to do it...

    Adding your own HTML

    Getting ready

    How to do it...

    See also

    4. Saving Form Data in the Database

    Introduction

    Creating a table to save your results and linking your form to it

    Getting ready

    How to do it...

    How it works...

    Using the options in Create Table

    Checkbox groups and multi-select drop-downs

    See also

    Viewing your saved form results

    Getting ready

    How to do it...

    See also

    Updating and changing DB Connections

    Getting ready

    How to do it...

    There's more...

    Removing an input

    Reordering columns

    Updating the e-mail template

    Exporting your results to Excel or a CSV file

    Getting ready

    How to do it...

    How it works...

    5. Form Validation and Security

    Introduction

    Making required fields

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Specifying the types of input that are allowed — text, numbers, dates, and so on

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Customizing validation error messages

    Getting ready

    How to do it...

    How it works...

    Adding extra security with server-side validation of submitted information

    Getting ready

    How to do it...

    How it works...

    There's more...

    Adding several validations

    Combining error messages

    Styling error messages

    Checking the database in a validation

    Filtering form data

    See also

    Getting the user to confirm their data before submission

    Getting ready

    How to do it...

    How it works...

    See also

    Adding an ImageVerification captcha / anti-spam check

    Getting ready

    How to do it...

    How it works...

    There's more...

    Debugging when the Captcha image won't display

    Debugging when you see a server error

    Changing the layout of the ImageVerification element

    Adding a refresh link to the Image Verification element

    See also

    Adding a reCAPTCHA anti-spam check

    Getting ready

    How to do it...

    How it works...

    There's more...

    Configuring the reCAPTCHA plug-in

    reCAPTCHA keys

    reCAPTCHA setup options

    Problems with reCAPTCHA

    See also

    Limiting form access to registered users

    Getting ready

    How to do it...

    How it works...

    There's more...

    Redirecting the user

    Redirecting the user with a message

    See also

    6. Showing your Form in your Site

    Introduction

    Including your form in an article using the ChronoForms plugin

    Getting ready

    How to do it...

    How it works...

    There's more...

    Debugging the ChronoForms plugin

    See also

    Showing your form on selected pages using the ChronoForms module

    Getting ready

    How to do it...

    How it works...

    There's more...

    Controlling the display of a module

    See also

    Linking to your form from Joomla! menus

    Getting ready

    How to do it...

    How it works...

    There's more . . .

    Passing extra parameters

    Creating administrator menu items

    Using a form to create a Joomla! article

    Getting ready

    How to do it...

    How it works...

    See also

    Redirecting users to other Joomla! pages after submission

    Getting ready

    How to do it...

    How it works...

    There's more...

    Showing a message after redirection

    Showing a message before redirection

    Redirecting conditionally

    See also

    7. Adding Features to your Form

    Introduction

    Adding a validated checkbox

    Getting ready

    How to do it...

    How it works...

    There's more...

    Validating the checkbox server-side

    Locking the Submit button until the box is checked

    See also

    Adding an other box to a drop-down

    Getting ready

    How to do it...

    How it works...

    There's more...

    Hiding the whole input

    See also

    Sending an SMS message on submission

    Getting ready

    How to do it...

    How it works...

    Signing up to a newsletter service

    Getting ready

    How to do it...

    How it works...

    See also

    Adding a conversion tracking script

    Getting ready

    How to do it...

    Showing a YouTube video

    Getting ready

    How to do it...

    How it works...

    Adding a barcode to a form e-mail

    Getting ready

    How to do it...

    How it works...

    There's more...

    Adding a character counter to a textarea

    Getting ready

    How to do it...

    How it works...

    Creating a double drop-down

    Getting ready

    How to do it...

    There's more...

    See also

    8. Uploading Files from your Forms

    Introduction

    Adding a file upload field to your form and setting the allowed types and sizes

    Getting ready

    How to do it...

    How it works...

    See also

    Saving files to different folders

    Getting ready

    How to do it...

    How it works...

    There's more...

    Renaming files

    Getting ready

    How to do it...

    How it works...

    Linking files to e-mails

    Getting ready

    How to do it...

    How it works...

    Resizing and copying image files

    Getting ready

    How to do it...

    How it works...

    See also

    Displaying images in e-mails and articles

    Getting ready

    How to do it...

    There's more...

    Adding an image to an article

    See also

    Troubleshooting problems with files

    Getting ready

    How to do it...

    See also

    9. Writing Form HTML

    Introduction

    Moving an existing form to ChronoForms

    Getting ready

    How to do it . . .

    How it works...

    Moving a form with JavaScript

    Getting ready

    How to do it...

    There's more...

    Changing the form name in ChronoForms

    Fixing conflicts with scripts using jQuery

    Loading snippets into the page head

    Moving a form with CSS

    Getting ready

    How to do it...

    There's more...

    Loading snippets into the page head

    Loading browser-specific CSS files into the page head

    Creating a form with Wufoo

    Getting ready

    How to do it...

    How it works...

    There's more...

    Changing the Wufoo theme template

    Using a form from the Wufoo gallery

    Adding validation to a Wufoo Form

    Creating a form in Dreamweaver

    Getting ready

    How to do it...

    10. Creating Common Forms

    Introduction

    Creating a simple newsletter signup

    Getting ready

    How to do it...

    See also

    Creating a form to link to Acajoom

    Getting ready

    How to do it...

    There's more...

    Creating a form to publish a Joomla! article

    Getting ready

    How to do it...

    See also

    Creating a Contact us form

    Getting ready

    How to do it...

    How it works...

    There's more...

    Creating an image or document upload form

    Getting ready

    How to do it...

    There's more...

    Adding a file upload to an existing form

    See also

    Creating a multi-page form

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    11. Using Form Plug-ins

    Introduction

    Controlling form access by user group, day, and/or time with the Watchman plug-in

    Getting ready

    How to do it...

    How it works...

    See also

    Creating multi-lingual forms with the Multi-Language plug-in

    Getting ready

    How to do it...

    How it works...

    There's more...

    Translating form error messages

    Translating form images

    Translating more complicated code

    Including HTML

    Including files

    Including variables

    Translating e-mail templates and thank you pages

    Showing and editing saved information with the Profile plug-in

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Registering users with the Joomla! Registration plug-in

    Getting ready

    How to do it...

    How it works...

    There's more...

    Sending custom e-mails

    Displaying custom messages

    Creating a silent registration

    Creating a Name from other field inputs

    Creating a Username from other fields

    Allowing secret registration

    Logging in new members automatically

    Saving extra data

    Changing user parameters

    Creating a PayPal purchase form with the ReDirect plug-in

    Getting ready

    How to do it...

    See also

    12. Adding Advanced Features

    Introduction

    Using PHP to create select dropdowns

    Getting ready

    How to do it . . .

    How it works...

    There's more...

    Creating numeric options lists

    Creating a drop-down from an array

    Using Ajax to look up e-mail addresses

    Getting ready

    How to do it . . .

    How it works...

    Getting information from a DB table to include in your form

    Getting ready

    How to do it...

    How it works...

    See also

    Show a form in a light-box

    Getting ready

    How to do it...

    How it works...

    There's more...

    Keeping our options open

    Adding PHP to the page

    Tracking site information

    Getting ready

    How to do it...

    Controlling e-mails from form inputs

    Getting ready

    How to do it...

    There's more...

    Disabling e-mails

    Changing the attached files

    See also

    Building a complex multi-page form

    Getting ready

    How to do it...

    See also

    Troubleshooting problems with forms

    How to do it...

    See also

    Index

    ChronoForms 3.1 for Joomla! Site Cookbook


    ChronoForms 3.1 for Joomla! Site Cookbook

    Copyright © 2010 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: August 2010

    Production Reference: 2131010

    Published by Packt Publishing Ltd.

    32 Lincoln Road

    Olton

    Birmingham, B27 6PA, UK.

    ISBN 978-1-849510-62-2

    www.packtpub.com

    Cover Image by Vinayak Chittar (<vinayak.chittar@gmail.com>)

    Credits

    Author

    Bob Janes

    Reviewers

    Laurelle Keashley

    Norm Douglas

    Acquisition Editor

    Usha Iyer

    Development Editor

    Mehul Shetty

    Technical Editors

    Tariq Rakhange

    Krutika V. Katelia

    Indexer

    Rekha Nair

    Editorial Team Leader

    Mithun Sehgal

    Project Team Leader

    Priya Mukherji

    Project Coordinator

    Zainab Bagasrawala

    Proofreader

    Aaron Nash

    Graphics

    Geetanjali Sawant

    Production Coordinator

    Arvindkumar Gupta

    Cover Work

    Arvindkumar Gupta

    About the Author

    Bob Janes started programming with punched cards a long time ago. As the Finance Director of a multi-national business, he kept his finger in the IT pie, much to the chagrin of those in corporate IT, and delivered innovative and successful systems projects ranging from foreign exchange to manufacturing.

    More recently, he has been able to return to hands-on coding and learned the basics of CMS coding with E-Xoops before turning his hand to Joomla! and WordPress. Bob enjoys learning through answering questions and has made more than 14,000 posts in the ChronoForms forums over the last few years.

    Bob divides his time between Brittany and London, and divides his work between coding and coaching — he has Bachelor's degrees in both Mathematics and Psychology and a Master's degree in Organisational Consulting.

    I'd like to thank Max who developed ChronoForms, and all the ChronoForms users whose questions made this book possible; my wife, Jane, who puts up with my hours in front of my keyboard; and my father who set me off on this path many years ago.

    About the Reviewer

    Laurelle Keashly graduated with a B.Sc in Computer Science from the University of Calgary. After graduating, Laurelle moved to the Vancouver, BC metropolitan area where she has done software programming, user interface design, and development team management for embedded communication and PC based accounting systems. Taking some time off to raise a family in the Burnaby, BC area, Laurelle got into website design, development, and support with local non-profit organizations. As her family has grown, her interest in web technologies grew to where she started Keashly.ca Consulting which provides the full spectrum of website development, support, and services with a specialty in Joomla! CMS-based sites. Laurelle is a moderator and an active member of the Joomla! forum and has created and released several Joomla! extensions. Laurelle continues to explore and provide up-to-date web-based services by actively keeping herself aware and supporting other CMS systems besides Joomla! such as Wordpress and Drupal.

    Norm Douglas loves technology. He has always built websites from as early as 1997. While researching and trying to develop his own rudimentary CMS from PHP, Norm stumbled upon Mambo, the precursor of Joomla!.

    Seeing the benefits not only to him as a developer but also to his clients, Norm immediately set about learning everything he could about PHP, MYSQL, CSS, CMS, and ultimately, Joomla!.

    Norm's broad range of IT experience and skills come together to make him an excellent all-round tutor. Not happy with just showing you how to do x and y, Norm will explain concepts to you. His goal is to help as many people as he can become better developers, webmasters, content managers, or just contributors as he is, so that the open source community may grow larger.

    He also runs TeachingJoomla.com, a subscription-based site for Joomla enthusiasts and those that manage their own site. Norm is also behind RedsourceMedia.com and is the lead developer at KeyVision.com.au.

    Preface

    Joomla! is a fantastic way to create a dynamic CMS. Now, you want to go to the next step and interact with your users. Forms are the way you ask questions and get replies. ChronoForms is the extension that lets you do that and this book tells you how.

    From building your first form to creating rich, form-based applications, we will cover the features that ChronoForms offers you in a clear hands-on way. Drawing on three years' daily experience of using ChronoForms and supporting users, there is valuable help for new users and experienced developers alike.

    We will take you through form development step-by-step from creating your first form using ChronoForms' built-in drag-and-drop tool, validating user input, emailing the results, saving data in the database, showing the form in your Joomla! site, and much more. Each chapter addresses a topic like validation or e-mail and each of the recipes in the chapters address the questions of different users from the beginner's question such as How do I set up an email? to more advanced questions like using some PHP to create a custom e-mail Subject line. Over 12 chapters and 80 recipes we cover all of the Frequently Asked Questions that new users and developers have about using ChronoForms. The recipe structure allows you to pick and choose just the solution that you need.

    This practical book, packed with easy-to-flow recipes, tips, and tricks, will help you add interactive forms to your sites with the ChronoForms.

    What this book covers

    Chapter 1, Creating a Simple Form: This chapter will teach you how to download and install ChronoForms, create your first form with the drag-and-drop Form Wizard, send the form results by e-mail, customize the e-mail, show a thank-you page to the user, edit your form with the Wizard Edit, re-direct the user after they submit the form, back up, and restore your forms.

    Chapter 2, E-mailing Form Results: This chapter covers sending form result to an administrator, getting your e-mails delivered safely, sending a message to the form user, sending emails to different people depending on the form results, attaching uploaded files to an email, sending a file to the user, and creating an e-mail subject line from the form results.

    Chapter 3, Styling your Form: The topics covered use the ChronoForms built-in styles, switching to another form template, adding your own CSS, using the Wizard Edit to put several form inputs in one line, and changing the layout by adding your own HTML.

    Chapter 4, Saving Form Data in the Database: The topics covered are creating a database table and linking your form to it, updating and changing database connections, viewing the saved data, and exporting data to Excel or CSV.

    Chapter 5, Form Validation and Security: This chapter covers making form fields required with ChronoForms built-in validation, specifying the type of input required, customizing validation messages, adding extra server-side validation, getting the user to confirm their results, adding a ChronoForms captcha check to your form, using a ReCaptcha check instead, and limiting form access to registered users.

    Chapter 6, Showing your Form in your Site: This covers showing your form in an article, or on selected pages in a module, linking to your form from a menu, using a form to create an article, and redirecting users to other Joomla! pages.

    Chapter 7, Adding Features to your Form: Here we take a look at some ways to use ChronoForms, such as adding a terms and conditions checkbox, linking an other box to a select drop-down, sending an SMS message when the form is submitted, signing up to an off-site newsletter service, adding a Google conversion tracking script, showing a YouTube video, adding a barcode to an e-mail, adding a character counter to a textarea input, and creating a double drop-down where the second changes depending on the first.

    Chapter 8, Uploading Files from your Forms: This chapter covers setting up file uploads, choosing where to save files, changing file names, linking flies to emails, resizing and copying uploaded image files, showing uploaded images in articles and emails, and troubleshooting file uploads.

    Chapter 9, Writing Form HTML: Moving existing forms to ChronoForms; moving a form that uses JavaScript; and CSS; creating forms in Dreamweaver.

    Chapter 10, Creating Common Forms: In this chapter, we create forms for newsletter sign-ups, Contact Us, link to a Joomla! component like Acajoom, publish an article, image or document upload, and a multi-page form.

    Chapter 11, Using Form Plug-ins: This chapter covers using ChronoForms plugins for extra performance: manage for access by user group or date and time, create multi-lingual forms, show and edit a saved record, register Joomla! users, and create a PayPal payment form.

    Chapter 12, Adding Advanced Features: This chapter covers using AJAX with a form, using PHP to create select drop-downs, getting information from the database to use in your form, showing a form in a light box, tracking the page that the form was submitted from, controlling e-mails from form data, building a complex multi-page form, and hints and tips for troubleshooting your forms.

    What you need for this book

    You will need administrator access to a Joomla! 1.5 installation. In order to run Joomla! 1.5, the minimum requirement is to use a server running PHP 4.3.10, MySQL 3.23, and Apache 1.3 IIS 6.

    Some parts of ChronoForms use functionality only available in PHP 5 and we recommend that you use the Joomla! -recommended specifications which are currently: PHP 5.2 or higher; MySQL 4.1 or higher, and Apache 2 or IIS 7.

    You will also need to download the the latest release of the ChronoForms extension for Joomla!. Instructions for this are provided in Chapter 1.

    Note: ChronoForms makes extensive use of the MooTools JavaScript library. Mootools version 1.1.2 is installed with Joomla!. The latest Joomla! Rrelease includes an option to enable MooTools 1.2.4 -— ChronoForms 3.1 will not run correctly if this option is enabled,.

    Who this book is for

    This is a practical hands-on book for people who want to add forms to their Joomla! site. Whether you just want to add a simple newsletter sign-up form or a complex multi-page interactive form, you'll find helpful suggestions and recipes that will get your forms working.

    Many recipes will work out of the box using ChronoForms built-in capabilities. Other more advanced recipes require some knowledge of Joomla!, HTML, CSS, PHP, MySQL, or JavaScript. There is a working code with each recipe that you can adapt to, to meet your specific needs.

    Conventions

    In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

    Code words in text are shown as follows: Message 5 in Section 3 is the $_POST array.

    A block of code is set as follows:

    $form_id = $MyForm->formrow->id;

    $MyUploads =& CFUploads::getInstance($form_id);

    $MyUploads->attachments[] = 'images/newsletter.pdf';

    ?>

    When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

    if ( !$mainframe->isSite() ) {return;}

    function createRangeSelect($label, $name, $start, $end) {

     

    ?>

    form_item>

    New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: Save the form and go to the Admin | Extensions | Module Manager.

    Note

    Warnings or important notes appear in a box like this.

    Tip

    Tips and tricks appear like this.

    Reader feedback

    Feedback from our readers is always welcome. Let us know what you think about this book — what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

    To send us general feedback, simply send an e-mail to <feedback@packtpub.com>, and mention the book title via the subject of your message.

    If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

    If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

    Customer support

    Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

    Tip

    Downloading the example code for this book

    You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Errata

    Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books — maybe a mistake in the text or the code — we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

    Piracy

    Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

    Please contact us at <copyright@packtpub.com> with a link to the suspected pirated material.

    We appreciate your help in protecting our authors, and our ability to bring you valuable content.

    Questions

    You can contact us at <questions@packtpub.com> if you are having a problem with any aspect of the book, and we will do our best to address it.

    Chapter 1. Creating a Simple Form

    In this chapter, we will cover:

    Downloading and installing ChronoForms

    Creating a simple form with the Form Wizard

    Sending the form results by e-mail

    Formatting your e-mail

    Showing a Thank You page

    Editing your form with the Wizard Edit

    Redirecting the user to another page

    Backing up and restoring your forms

    Introduction

    Let's say that we want to add a very simple form to our Joomla! site. Probably the simplest is a newsletter sign-up. We will just collect the user's e-mail address and send the result to the site administrator. Later, in the book we'll be able

    Enjoying the preview?
    Page 1 of 1