CRG PHPlugins Hooks

From version 4.0.5 onward, TTG CE2 Client Response Gallery supports two special PHPlugins hooks which are not available to other plugins. This pages addresses only these exclusive PHPlugins hooks; for more general information on using PHPlugins in CE2 engines, see the PHPlugins documentation.

ttg_form_action

  • if return = false normal TTG <form> processing is skipped
  • called at the opening of the CRG gallery HTML form
  • encompasses the opening of the <form> element (see below)

This hook can be used to replace the opening of the <form> element which encompasses the image grid, response options and submission form on the client response gallery page. Use this hook to replace the default form action. The default form action looks like this:

<form action="./resources/php/FormToEmail.php" method="post" id="response">

I recommend using this snippet as a base for your modifications, keeping the method and id intact. An example use of this hook would be to reroute all CRG galleries to use a single instance of the FormToEmail.php script stored in a universally accessible location of your site, or to implement a separate script altogether, whether Form-to-Email Pro or a different script entirely (at your own liability, of course).

If using the FormToEmail.php script from a universal location, be mindful of your “Return-to Location” ($continue), and that it is set appropriately, maybe pointing back at your Home page or gallery index, or using Javascript to return the user to the previous page:

javascript:javascript:history.go(-1)

ttg_form_fields

Use this hook to replace the gallery submission form. The default form makes a good base; I would recommend using the form as-is and adding to it, rather than taking things away. You can safely remove the Telephone and Website fields, though. Again, use at your own discretion and liability. The default form looks like this:

<input name="Select-Count" type="hidden" value="" class="report-count" />
<input name="Gallery-Title" type="hidden" value="ALBUM TITLE" />
<input name="Gallery-URL" type="hidden" value="<?php echo currentPageURL(); ?>" />

<fieldset><label for="field1">Name</label>
<div>
<input id="field1" name="name" type="text" size="30" tabindex="1" required />
</div>
</fieldset>

<fieldset><label for="field2">Email</label>
<div>
<input id="field2" name="email" type="text" size="30" tabindex="2" required />
</div>
</fieldset>

<fieldset><label for="field3">Telephone</label>
<div>
<input id="field3" name="telephone" type="text" size="30" tabindex="3" />
</div>
</fieldset>

<fieldset><label for="field4">Website</label>
<div>
<input id="field4" name="website" type="text" size="30" tabindex="4" />
</div>
</fieldset><% end %>

<fieldset><label>Message</label>
<div>
<textarea name="message" id="comments" tabindex="5" rows="1" cols="1"></textarea>
</div>
</fieldset>

<fieldset><input type="submit" id="crg-submit" value="Send" /></fieldset>

An example use for this hook might be to add an email confirmation (enter email a second time) to your form after upgrading to Form-to-Email Pro.

Example Functions

Below, example functions you may use as a starting point when using the above hooks. It is not necessary to use both functions if you don't need both. Form example, you may change the input fields array (ttg_form_fields) without changing the default form action.

/* DELETE THIS LINE
// CHANGE FORM ACTION FOR CLIENT RESPONSE GALLERY
// Replaces the default <form> element in CRG galleries
// Serves as an example of a function being applied globally
function ttg_form_action( $style, $path ) { 
	if (G_STYLE == 'CE2-CLIENTRESPONSE') {
		echo '
	
<form action="./resources/php/FormToEmail.php" method="post" id="response">

		';
		return false;	// Replaces default <form> element
	}
	return true;
} // END
DELETE THIS LINE */




/* DELETE THIS LINE
// REPLACE SUBMISSION FORM IN CLIENT RESPONSE GALLERY
// Replaces the default <input> elements array in CRG galleries
// Serves as an example of a function being applied globally
function ttg_form_fields( $style, $path ) { 
	if (G_STYLE == 'CE2-CLIENTRESPONSE') {
		echo '
	
<!-- insert form inputs here -->

		';
		return false;	// Replaces default <input> elements array
	}
	return true;
} // END
DELETE THIS LINE */
Print/export