RSForm!Pro Manage Directories Scripting Examples

Similar to the form configuration, the Manage directories section also offers a scripting area that can be used to further control the functionality of the front-end submissions editing feature. This can be accesed from Components > RSForm!Pro > Manage directories by selecting the form you want to edit and going to the PHP Scripts tab.

There are three areas available in the PHP Scripts section, in this article we will present a simple script for each area:


Scripts called on listing layout

The scripts from this area will be triggered when the initial submissions listing page is accessed. The $directoryLayout variable contains all the HTML code of the page. The following script will add a simple message before the submissions are listed using the name of the currently logged in user.

    $user = JFactory::getUser();
    $directoryLayout = "<p>Hello ".$user->get('name').", the submissions are listed below.</p>".$directoryLayout;

Scripts called on details layout

These scripts are triggered when the submission details page is accessed (through the View icon). The $detailsLayout variable contains all the HTML code of the page. You could use the following script in order to display the submission id in this layout.

    $submissionId = JFactory::getApplication()->input->getInt('id');
    $detailsLayout = "<p>You are now editing the submission with id ".$submissionId.".</p>".$detailsLayout;

Script called before the Directory Emails are sent

This area is similar to the PHP Email Scripts and will be triggered before the directory emails will be sent. You can use this section in order to perform additional operations when a submission is edited. In the following script we will change the submission date with the current date for the submission we are editing

    $submissionId = JFactory::getApplication()->input->getInt('id');
    $db = JFactory::getDbo();

    $db->setQuery("UPDATE #__rsform_submissions SET `DateSubmitted`='".date('Y-m-d G:i:s')."' 
    WHERE `SubmissionId`='".$submissionId."'");
    $db->execute();  // if you are using Joomla! 2.5 you will need to replace this line with $db->query();

Note!
If you do not have any emails defined for the current directory the scripts from this section will not be triggered. Please make sure that you have at least one email defined in the Emails tab.


14 persons found this article helpful.


Was this article helpful?

Yes No
Sorry about that