Recent Topics

1 Nov 09, 2011 00:33    

My b2evolution Version: 4.1.x

Hi all,

I've tried digging through various AJAX form resources for this, but haven't found anything that helps me understand what I want to do.

Basically, I want to add a dropdown list to the standard Contact form that contains a list of departments that the sender can pick from to help the admin route the e-mail to the proper person.

Where would I add the code for the dropdown list? In _msgform.disp.php? If so, where in that file would the code need to go?

Thanks in advance,
Stace

2 Nov 17, 2011 02:32

You can't just add the select field with options, you will also need to get posted value and process it.

The easiest and safest way to do that is create a plugin. Here's a sample plugin.

<?php
/**
 * @license GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
 *
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );


class custom_plugin extends Plugin
{
	var $name = 'Custom plugin';
	var $code = 'CstmPlug';
	var $priority = 50;
	var $version = '0.1';
	var $author = '';
	var $author_url = '';

	var $apply_rendering = 'stealth';
	var $number_of_installs = 1;
	
	/**
	 * Init
	 */
	function PluginInit( & $params )
	{
		$this->short_desc = $this->T_('Extends b2evo functionality');
		$this->long_desc = $this->short_desc;
	}
	
	
	function DisplayMessageFormFieldset( & $params )
	{
		$input = '<select name="my_param">
					<option value="sales">Sales dept</option>
					<option value="other">Other dept</option>
				  </select>';
		
		$params['Form']->info( 'Select one', $input );
	}
	
	
	function MessageFormSent( & $params )
	{
		global $recipient_address, $recipient_name;
		
		if( $department = param('my_param', 'string') )
		{
			switch( $department )
			{
				case 'sales':
					// Override default recipient name and email
					$recipient_address = 'sales@domain.tld';
					$recipient_name = 'Sales department';
					break;
				
				case 'other':
					$recipient_address = 'other@domain.tld';
					$recipient_name = 'Other department';
					break;
			}
		}
	}
}

?>

3 Nov 17, 2011 17:33

Thanks, sam2kb. I'll play with this when I get a chance, but it will probably be a while. I'm currently being pulled in a different direction at work.


Form is loading...