Mailback custom HTML and Subject - MultiLanguge

  • Posts: 13
  • Thank you received: 0

maikla73 replied the topic: Mailback custom HTML and Subject - MultiLanguge

Hello,

I was very happy to found here a solution for customized emails in different languages.
I use the code below and it works fine.
The only problem I have is that the [_FF_DATA_TITLE] is coming in the email only in German language.
And the image is not shown in the email.

Any idea how I can fix this?
Another question is can I modify the content that the labels and values are in a table?
$this->execPieceByName('ff_InitLib');
$lang = JFactory::getLanguage();
$lang_tag = $lang->getTag();
$from = 'info@test.com'; 
$fromname = 'TEST'; 

$recipient = ff_getSubmit('email');

$body1 = '<html><body>
<p><img src="images/content/Logo.png" /></p>
<p>Thank you very much for your interest.</p>
<p>If you have more questions dont hesitate to contact us.</p>
<p>Just reply to this email.</p>
<p>_____________________________________________________________________________</p>
';

//Add form values to the custom email content
foreach ($this->maildata as $data) {
$body1 .= '<br>' . $data[_FF_DATA_TITLE].': '.$data[_FF_DATA_VALUE]. '<br>';
}

$body1 .='</body></html>';

$body2 = '<html><body>
<p><img src="images/content/Logo.png" /></p>
<p>Vielen Dank für das Interesse an.</p>
<p>Sollten Sie weitere Fragen haben zögern Sie nicht uns anzusprechen.</p>
<p>Antworten Sie einfach auf diese Email.</p>
<p>_____________________________________________________________________________</p>
';

//Add form values to the custom email content
foreach ($this->maildata as $data) {
$body2 .= '<br>' . $data[_FF_DATA_TITLE].': '.$data[_FF_DATA_VALUE]. '<br>';
}

$body2 .='</body></html>';

if ($lang_tag == 'en-GB') {
$isHtml = true;
$subject = "English";
$this->sendMail($from, $fromname, $recipient, $subject, $body1, $attachment, $isHtml);
}
if ($lang_tag == 'de-DE') {
$isHtml = true;
$subject = "German";
$this->sendMail($from, $fromname, $recipient, $subject, $body2, $attachment, $isHtml);
}

Thank you in advance and KR
Maik
#233646
  • Posts: 2483
  • Karma: 86
  • Thank you received: 335

mihaela replied the topic: Mailback custom HTML and Subject - MultiLanguge

Hello,

I'm glad that you've found the functionality you needed.

You wrote "The only problem I have is that the [_FF_DATA_TITLE] is coming in the email only in German language." . I am not sure whether this can be solved without quite a bit of additional coding, but please try to use $data[_FF_DATA_NAME] instead of $data[_FF_DATA_TITLE] and see what happens.

As for the image which is not shown, please try to put the absolute path as image "src" instead of putting relative path.

To display data submitted in the form in a table, try to replace this piece of code:
foreach ($this->maildata as $data) {
$body1 .= '<br>' . $data[_FF_DATA_TITLE].': '.$data[_FF_DATA_VALUE]. '<br>';
}

with the following one:
$body1 .= '<table width="100%" border="1" cellpadding="5">';
foreach ($this->maildata as $data) {
	$body1 .= '<tr><td>' .  $data[_FF_DATA_TITLE] .'</td><td>' . $DATA[_FF_DATA_VALUE] . '</td></tr>';
}
$body1 .= '</table>';

Let me know whether this helped and whether you've managed to set it to work for your form.

Regards,

Mihaela
#233649
  • Posts: 13
  • Thank you received: 0

maikla73 replied the topic: Mailback custom HTML and Subject - MultiLanguge

Hi Mihaela,

thank you for quick reply.
The [_FF_DATA_NAME] doesn't work, I still get only German titles.
The table and image are fine now.

Is it possible to create a table manually that I can define by myself which data are in the email and which not?

Then I can set German and English labels manually.

Thank you and KR
Maik
#233650
  • Posts: 2483
  • Karma: 86
  • Thank you received: 335

mihaela replied the topic: Mailback custom HTML and Subject - MultiLanguge

Hello,

Yes, it is possible to create a table manually, in a way that you put there elements and titles that you want.

That was what I planned to suggest if your form is not too lengthy.

There are two ways that you can grab the values submitted in the form.
First way is to get values like this:
$adresse= ff_getSubmit('adresse');

For example, for English version you could then use this code:
$adresse= ff_getSubmit('adresse');
$body1 .= '<table width="100%" border="1" cellpadding="5">';
	$body1 .= '<tr><td>Address: </td><td>' . $adresse . '</td></tr>';

$body1 .= '</table>';

This is just an example for one field named "adresse" in German form. You would add here as many table rows as needed.

The other solution is to add if condition for EACH FORM FIELD in foreach loop. Here is an example for name:
$body1 .= '<table width="100%" border="1" cellpadding="5">';
foreach ($this->maildata as $data) {
    if( $data[_FF_DATA_TITLE] == "adresse") {
	    $body1 .= '<tr><td>Address: </td><td>' . $DATA[_FF_DATA_VALUE] . '</td></tr>';
	}
}
$body1 .= '</table>';
NOTE: This example will avoid empty lines in case some form element isn't filled in.

Let me know whether you've managed to set this to work as you wanted.

Regards,

Mihaela
#233676
  • Posts: 13
  • Thank you received: 0

maikla73 replied the topic: Mailback custom HTML and Subject - MultiLanguge

Hello Mihaela,

thank you very much, it works perfectly.

Just some short questions.
Is it possible to add a link to the image?
Is it posibble to add a mailto link for text?
And ist is possible to modify font size and colour?

Thank you very much for support and KR
Maik
#233698
  • Posts: 2483
  • Karma: 86
  • Thank you received: 335

mihaela replied the topic: Mailback custom HTML and Subject - MultiLanguge

Hello again,

I'm glad that it is working.

Here are the answers to your other questions.

1. Yes, it is possible to add a link to the image:
Here is an example how you can do so:
<a href="https://www.google.com/">
<img border="0" alt="Smiley" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/SNice.svg/220px-SNice.svg.png" width="100" height="100">
</a>
NOTE: replace " www.google.com/ " with the address you wish to link, and " upload.wikimedia.org/wikipedia/commons/t.../220px-SNice.svg.png " with the image that you wish to be displayed.

If what you wanted to know is how to have a link pointing to an image, you can do it the following way:
<a href="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/SNice.svg/220px-SNice.svg.png">Image link</a>

2. You wrote "Is it possible to add a mailto link for text?". I'm not sure what you want to achieve, can you please explain a bit more?

3. It is possible to modify font-size and color. You should simply add css code for that. For example, like this:
<p style="font-size:20px; color:blue;">

Let me know whether you've managed to set this for your form (email).

Regards,

Mihaela
#233701
Moderators: ForumSupporttomeperica
Time to create page: 0.081 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here