[SOLVED] Email template | PHP issue + SOLUTION

marcq

Member
Fabrik : 3.5.1
Joomla : 3.5.1

Hi,

Sorry to bother with this issue, but I have no clue why it is not working.

I'm would like to add into my email template a else elseif loop to display or not specific informations with two conditions :

Code:
$type     = '{gprh_fabrik_user_reminder___type_rappel_raw}';
$rappel = '{gprh_fabrik_user_reminder___no_rappel_raw}';
Which are radio-buttons values.

I was unable to get it work.

In my email template I have tested (var_dumped) if the values are returned, they are since the email generated is returning the values I'm looking for :

Code:
string(7) "type : " string(45) "3"

string(9) "rappel : " string(43) "1"

But when I'm using those values into a if elseif else loop, than the echoed value is always the "else" value -> nothing.

If I'm doing the following simple test :

Code:
<p><?php
         
            $type     = '{gprh_fabrik_user_reminder___type_rappel_raw}';
         
            echo $type;
         
            if ($type == 3)
                {
                echo 'YES!';
                }
            else
                {
                echo 'NO!';
                }
            ?></p>

The echoed values in the generated email are :

Code:
3 NO!

The correct value is always returned (3), the loop should echo 'YES' but still echoed is 'NO'.

No clue why it is not working, by the way I have tried several other ways to display the needed information without success, please see txt doc attached.

Would appreciate some help here.

Cheers, marc
 

Attachments

  • PHP-IF-ELSE-EMAIL-ISSUE.txt
    4.1 KB · Views: 162
Last edited:
string(7) "type : " string(45) "3"
As you can see "3" is not 3 but a string(45), so 44 characters not displayed (some HTML formatting etc).
But I have no idea why "_raw" is returning this.

Try to inspect the source code of this page displaying the dumps, maybe this gives a clue.
 
Ah, is the code in a file?
You can't use placeholders there, use $this->data['tablename___elementname'];

The debug problem is that in your code you get an output string "type : {xxxx}"
and this is run afterwards through the placeholder replacement replacing {xxxx} with 3
(drove me crazy some time ago, too:eek:)
 
Thanks a lot troester, was unable to solve it with the _raw value (I'm going crazy because I can't find an explanation to this behavior), but with the label value it is working fine.

So Problem solved, cheers, marc

Solution to whom it may interest :

PHP:
<?php
// GET THE ELEMENT VALUES
$rappel_cr1 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_cr1}';
$rappel_cr2 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_cr2}';
$rappel_cr3 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_cr3}';
$rappel_fr1 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_fr1}';
$rappel_fr2 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_fr2}';
$rappel_fr3 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_fr3}';
$rappel_fe1 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_fe1}';
$rappel_fe2 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_fe2}';
$rappel_fe3 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_fe3}';
$rappel_co1 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_co1}';
$rappel_co2 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_co2}';
$rappel_co3 = '{gprh_fabrik_user_reminder___bloc_objet_rappel_co3}';
?>

PHP:
<?php
       // GET THE RADIO-BUTTON VALUES
       $type = $this->data['gprh_fabrik_user_reminder___type_rappel'];
       $rappel = $this->data['gprh_fabrik_user_reminder___no_rappel'];
       // ECHOING THE APPROPRIATE VALUE
        if ($type == "Formation :<br>Contrat" && $rappel == "1er rappel") { echo $rappel_cr1;
        } elseif ($type == "Formation :<br>Contrat" && $rappel == "2?me rappel") { echo $rappel_cr2;
        } elseif ($type == "Formation :<br>Contrat" && $rappel == "3?me rappel") { echo $rappel_cr3;
        } elseif ($type == "Formation :<br>Facture" && $rappel == "1er rappel") { echo $rappel_fr1;
        } elseif ($type == "Formation :<br>Facture" && $rappel == "2?me rappel") { echo $rappel_fr2;
        } elseif ($type == "Formation :<br>Facture" && $rappel == "3?me rappel") { echo $rappel_fr3;
        } elseif ($type == "Membre :<br>Finance d'entr?e" && $rappel == "1er rappel") { echo $rappel_fe1;
        } elseif ($type == "Membre :<br>Finance d'entr?e" && $rappel == "2?me rappel") { echo $rappel_fe2;
        } elseif ($type == "Membre :<br>Finance d'entr?e" && $rappel == "3?me rappel") { echo $rappel_fe3;
        } elseif ($type == "Membre :<br>Cotisation" && $rappel == "1er rappel") { echo $rappel_co1;
        } elseif ($type == "Membre :<br>Cotisation" && $rappel == "2?me rappel") { echo $rappel_co3;
        } elseif ($type == "Membre :<br>Cotisation" && $rappel == "3?me rappel") { echo $rappel_co3;
        } else { echo "Ooops"; }
?>
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top