21 Posts
ralle
7 years ago
Topic

Hello anybody, i have a proplem to render a groupx field in a email. The tut:

https://www.seblod.com/resources/tutorials/rendering-a-groupx-field-in-an-email and the

https://www.seblod.com/resources/tutorials/calling-field-x-and-group-x-content-in-an-override tut is not a help. With the editor field from eMail-field there give me in my email the groupx without label. With the beforestore field and the foreach call it will be the numbers of the groupx-fields without label and value... what better solutions are there to fix this?

Get a VIP membership
4229 Posts
Kadministrator
7 years ago
1
Level 1

Please explain what is the problem, you can get label and other properties as with other fields, the same way as value from groupX field and it's child fields ($cck->getLabel - see tutorial), difference is jsut in a loop that is needed.

21 Posts
ralle
7 years ago
0
Level 2

Thanks Klas for your support.

When saving the article an e-mail with all filled fields should be sent including a groupx.send I with # groupx # the group in the editor of the email field on I get all group fields with a point as label and behind the field value. This output should however look in the email as the group fields in the content. Since the group fields are not rendered clearly over the email field now an afterstore field and an htmlfeld was created. This solution does not function somehow.

7 years ago
1
Level 1

Hello I tried to help ralle, he contacted me via email. So I tried to figure the problem out.

When I call my GroupX Field in beforestore like:

foreach($fields['geladen_in']->value as $gx){
$land = $gx['gel_in_land']->value;
}

I supposed to get the value of the Field "gel_in_land", butI get in fact nothing. If I call the position $fields['geladen_in']->value (the GroupX-Field) and echo it out, I get the integer of how many Groups I made.

So I tried also the other way described in the following tutorial:

https://www.seblod.com/resources/tutorials/rendering-a-groupx-field-in-an-email

but for me it's not clear how to fill the ALL THE VALUES (like label and so on) from my GroupX into that Textarea.

I tried with Afterstore Code like this:

$myGroupX = $fields['geladen_in']->value;

$fields['my_textarea']->value = $myGroupX;

Sory to say that (or maybe I'm dumb), but the explanation of the steps 2 and 3 isn't realy helpful.

I hope I could describe the problem corectly.

Thank you for your time.

Kiki

4229 Posts
Kadministrator
7 years ago
0
Level 2

Sorry, I forgot about his change in 3.10, I guess tutorials need an update, for field/groupX you need to use values property

https://www.seblod.com/community/forums/general-discussions/get-values-of-groupx-using-fields#50073

7 years ago
1
Level 1

Hello with the link you posted and this suggestion I tried another one:

$groupx = Array();
$groupx = $fields['testgroup']->values; // my GroupX Field

$sendingMail= "kiki@wwr-band.com";
$betreff = "Tourbericht";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
$headers .= "From:" . $Versandadresse." ";
/* To send HTML mail, you can set the Content-type header. */
mail("info@whykiki.de",$betreff,$groupx,$headers);

I tried If I could send anything but in this case the mail wouldn't be sent. What am I doing wrong??
4229 Posts
Kadministrator
7 years ago
0
Level 2

$groupx is an array, you can't use it as string in mail function. Also don't send email from after store or you will get 2 emails sent, you need to follow

https://www.seblod.com/resources/tutorials/rendering-a-groupx-field-in-an-email

Basically, you need to add some empty text field , and then in afterstore looop trough $groupx values and create html from that, easiest would be to just append html from each field from $groupX to some $html string.

At the end you need to set html property of your empty text field to this concatenated variable (see tutorial).

If you don't know how to code in php you need to get someone who does, php knowledge is required to use code plugins. You can also use Seblod services

7 years ago
1
Level 1

Got it working! Thank you for pointing me in the right direction. I used the following in BeforeStore:

$html = '';
$counter = 0;
foreach( $fields['testgroup']->values as $grouper){ // MyGroupX
$counter++;
$html .= "Label Testfeld Group ".$counter.":".$grouper['testfeld_group'] // My field in GroupX;
}

$Versandadresse = "mailfrom@mail.de";
$betreff = "Tourbericht";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
mail("mailtosendto@mail.de",$betreff,$html,$headers);

What I forgot before: On each loop he resetted my $html-Value and so I got only the values of the last group. Concatenating the $html did the trick...

This is if you only want to use the beforeStore for looping and sending the values. If you want to use the "normal" Email-Function from Seblod with the Standard-Mail-Field you have to:

1. build a new field from type "Textarea" and call it for example "my_groupx_html"
2. build a new beforeStore with this code:

$html = '';
$counter = 0;
foreach( $fields['testgroup']->values as $grouper){ // 'testgroupx' is the GroupX
$counter++;
$html .= "Label Testfeld Group ".$counter.":".$grouper['testfeld_group']."<br>";

// Here I call my Field "Testfeld Group" from the GroupX and adding the labels by myself
// I also add a counter to add a number to my Labels
}
$fields['testfeld']->value = $html;

So now you map all the content of your Variable $html to your Field my_groupx_html" you created in step 1

3. now you call call the Value of your Field in the Mail-Field like this:

#my_groupx_html#

and it will contain all the values and also the selfbuilt labels. I hope this explanation helps anyone else who stuck in this problem. Thanks again for the tip with values...

Greetings Whykiki

21 Posts
ralle
7 years ago
0
Level 2

Thank you klas and whykiki, the problem was solved with your help super.Whykiki has even made a manual. At https://www.youtube.com/watch?v=30dCYVNnRvQ the German Seblod users can understand the solution.

Best regards and a big praise to Whykiki

Get a VIP membership