Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Each checkbox item as a new line in email?

Each checkbox item as a new line in email? 6 years 9 months ago #27411

  • peterbat
  • peterbat's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 25
  • Thank you received: 0
Using 3.2.7, is it possible to get multiple checkbox responses from a single field to show in the registration email as new lines for each option selected?
Ideally, I would like the responses to be listed in the same way that the field does in the registration form when the "New lines" option is selected for that field.
If it is possible, how do I do it?
At present, all selected options run together, as a paragraph of text.
Thanks, Peter

Please Log in or Create an account to join the conversation.

Last Edit: by nathan.dth.

Each checkbox item as a new line in email? 6 years 9 months ago #27412

  • nathan.dth
  • nathan.dth's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 1857
  • Karma: 19
  • Thank you received: 218
We are modifying this for the next update, as it definitely makes more sense to display in emails on new lines. You can make these changes and get that:

/administrator/components/com_dtregister/lib/tagparser.php

Around line 192, BEFORE this line:
$tagvalues = $fieldTable->$function((array)$recipient,null,'',false);

Add this code:
if(is_callable(array($fieldTable,'emailView'))){
						  $function = 'emailView';
					  }

Then in this file:

/administrator/components/com_dtregister/models/field.php

Around line 2100, BEFORE this:
function getkeyByValue($value=array()){

Add this code:
function emailView($obj=null,$event=null,$form='',$overlimitdisable=false){

		 if(!is_array($this->values)){

		    $this->values = explode('|',$this->values);

		 }

		 $selected = array();
         
		 if(!isset($obj['fields'][$this->id])|| $obj['fields'][$this->id] ==  null){

			return false;

		 }

	     if (count($this->values) > 0) {
         foreach($this->values as $key=>$value){

		 if(!is_array($obj['fields'][$this->id])){

		   	$obj['fields'][$this->id] = explode("|",$obj['fields'][$this->id]);

		 }

		    if(in_array($key,$obj['fields'][$this->id])){

				$selected[] = $value;

		     }	 

		 }
         }
         
	     return implode("<br /> \n ",$selected); 

   }

That should get you what you are wanting. Thanks!
The following user(s) said Thank You: peterbat

Please Log in or Create an account to join the conversation.

Nathan is no longer affiliated with DTH since the recent acquisition. You can connect with him and get any type of Joomla website help at www.JoomlaEmployee.com .

Each checkbox item as a new line in email? 6 years 9 months ago #27413

  • peterbat
  • peterbat's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 25
  • Thank you received: 0
Thanks Nathan,
works perfectly!
I think it makes the formatting of the email response much better, particularly if there are commas in the various selected options.
Regards, Peter

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.274 seconds