Create a custom testimonial category with RSForm Pro and Joomla Content Component

If you use the mighty RSForm Pro from RSJoomla.com you probably have tapped into its ability to map the fields of your custom form to any database, and that is just awesome because it provides lots of flexibility. You can create forms to do just about anything that components do and map it all to Joomla's core article component. Wikkid!

One popular customization we have done for clients is that of creating special article types, like say a testimonial system with the output formatted as the following illustration

testimonial-sample.png

These steps assume you know the basics of creating a custom form with RSForm Pro.

First, create the RSForm Pro custom fields as below.

rsform-custom-fields.jpg

The 'hidden' inputs are needed to get data.

The 'date' hidden input gets the realtime from PHP based on your Joomla Global time setting. Enter the following into the Default Value field

//<code>
return strftime('%Y-%m-%d %H:%M:%S', time());
//</code>

It should look like this. The format is exactly as it needs to be for Joomla content database date and time of 2014-04-17 16:15:10. Do not change it!

rsform-hidden-field-date.jpg

For the Title Alias hidden input, just create it with the name only. Nothing should be placed in the Default Value field!

The next step will show how to create the Joomla system title_alias from the RSForm Pro custom title field.

Now switch to Properties and click PHP Scripts from the menu on the left

In the field for $_POST form data, enter the following. Do not use the php open and close tags.

$alias = $_POST['form']['title'];
$alias = strtolower($alias);
$alias = preg_replace('/\W/', '-', $alias);
$_POST['form']['titlealias']=$alias;

When the form posts, the script will get the text from the field named 'title', convert all letters to lowercase, strip any non-letter character, including blank spaces, and replace them with a hyphen, then finally assign the result to the 'titlealias' hidden field as value.

Now click Sql Mappings

Leave the selections as default to connect to the database that your Joomla installation is using and click Connect To Database.

Select the _content table. The prefix will be different for each installation.

Enter the RSForm Pro field hooks as below. Note that the image is a condensed view showing only the columns needed. Be sure to match accordingly.

rsform-sql-mappings-to-joomla-content.jpg

Of course you should have created the category where these entries will be stored. Enter the numerical ID of that category in the 'catid' column. The '0' in the 'state' column sets the entry to unpublished so you can review it then publish when you desire. Enter the user ID of a Super User in the 'created_by' column. The 'access' column with value '1' allows public view and finally the '*' in the 'language' column sets to 'all'.

Now you have a testimonial category without the need to install a specialized component to clutter your extension repository. All you need to do now is create a menu item to the category as Category Blog. You can use the CMSE RecentPost module (a rework of the popular AidaNews) to display extracts from the category as random, category order, latest entries and much more.

Note that you can use HTML elements in the 'introtext' column therefore being able to format the output any way you desire.

You can get really creative with this powerful RSForm Pro component and create any special component-like function you want and map the inputs to the core Joomla content component or any other component which you use.

A later post we will show how to create an event listing section with Joomla content and RSForm Pro.