Welcome, Guest
Username: Password: Remember me
If you expect answers you should describe your problem and give as much information's as possible. (SQL-Structure, Template Code, Joomla Version ...) Please read this before posting: joodb.feenders.de/support.html

TOPIC: Editing controller.php to change the email data?

Editing controller.php to change the email data? 1 year 3 weeks ago #1757

Hi All,

I wonder if someone could kindly help me,

I have a form using JooDatabase which sends me an email when someone submits it, I am trying to change the email subject and title

so i have looked in the controller.php file and have found the part that needs changing
		// send formdata to admin
		if ($params->get("infomail",0)==1) {
			$db->setQuery("SELECT email FROM `#__users` WHERE `id` ='".$params->get("infomail_user")."' LIMIT 1");
			if ($email = $db->loadResult()) {
				$MailFrom 	= $application->getCfg('mailfrom');
				$FromName 	= $application->getCfg('fromname');
				$subject = "JooDatabase - ".JText::_('New Database entry')." - ".$joodb->name;
				$body = $subject."\r\n";
				$body .= "Site: ".$application->getCfg('sitename')." - ".JUri::Current()."\r\n\r\n";
				$body .= JText::_('Recieved values')."\r\n===================\r\n";
				foreach ($item as $var=>$val) {
					$body .= ucfirst($var).": ".$val."\r\n";;
				}
				$body .= "===================\r\n".JText::_('Statusmessage').": ".$msg."\r\n\r\n";
				$mail = JFactory::getMailer();
				$mail->addRecipient( $email );
				$mail->setSender( array( $MailFrom, $FromName ) );
				$mail->setSubject( $FromName.': '.$subject );
				$mail->setBody( $body );
 
				$sent = $mail->Send();
			}
		}

what i want to acheive is change the subject so that it includes the gym_discipline field text that the user submitted, but im not sure how to grab that particular form fields submitted data?

can anyone help
Thanks

Luke
Last Edit: 1 year 5 days ago by joest.
The administrator has disabled public write access.

Re: Editing controller.php to change the email data? 1 year 3 weeks ago #1760

  • dirk
  • dirk's Avatar
  • OFFLINE
  • Posts: 437
  • Thank you received: 71
  • Karma: 9
ljackson1984 wrote:
what i want to acheive is change the subject so that it includes the gym_discipline field text that the user submitted, but im not sure how to grab that particular form fields submitted data.

Look here
$subject = "JooDatabase - ".JText::_('New Database entry')." - ".$joodb->name;

The received values are in the $item array
$subject = "JooDatabase - ".JText::_('New Database entry')." - ".$item->['gym_discipline'];

Be aware that all changes in the controller.php will be lost after the next update!
The administrator has disabled public write access.

Re: Editing controller.php to change the email data? 1 year 3 weeks ago #1768

Hi Dirk,

Thanks for your reply,

I'm having trouble pulling out the required data, and i think its because $item is not declaired until further in the script, so this line
$subject = "JooDatabase - ".JText::_('New Database entry')." - ".$item->['gym_discipline'];

is breaking the script as there is no $item until 3 lines later
$subject = "JooDatabase - ".JText::_('New Database entry')." - ".$item->['gym_discipline'];
				$body = $subject."\r\n";
				$body .= "Site: ".$application->getCfg('sitename')." - ".JUri::Current()."\r\n\r\n";
				$body .= JText::_('Recieved values')."\r\n===================\r\n";
				foreach ($item as $var=>$val) {
					$body .= ucfirst($var).": ".$val."\r\n";;
				}

at least thats what i think is happening? what ever it is that first line ($subject) is killing the script

any ideas please

Thanks
Luke
The administrator has disabled public write access.

Re: Editing controller.php to change the email data? 1 year 2 weeks ago #1778

ok tried it again and its now working :) not sure what i did wrong first time lol

is there any way to prevent the controller.php file from being overwritten following an update?

many thanks for your help
Luke
The administrator has disabled public write access.
Moderators: dirk, joest
Protected by R Antispam