This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

How to add custom template variables?


  1. Trowar
    Member

    Hi,

    I am using machform and wish to include custom template variables into my e-mails.

    For example. When an entry is entered added to the ap_form_1 table, my site automatically adds some additional fields (rvplace, rvtime, rvdate, payref, paystatus, etc..).

    In an e-mai I can put {element_1} in and it will populate from the machform database. How can I get my site to accept {rvplace} and to auto populate the field with that name from the database as well?

    Many Thanks,

    Peter Cunningham.

    Posted 14 years ago #
  2. yuniar

    I must say this one won't be quite simple to do.

    Basically, the code which parse the template variables is within the "includes/helper-functions.php" file.
    Around line 306, you'll see a bunch of code which creates the template variables and assign the values. This code:

    $template_variables[$i] = '{date_created}';
    $template_values[$i]    = $date_created;
    $i++;
    $template_variables[$i] = '{ip_address}';
    $template_values[$i]    = $ip_address;
    $i++;
    $template_variables[$i] = '{form_name}';
    $template_values[$i]    = $form_name;
    $i++;
    $template_variables[$i] = '{entry_no}';
    $template_values[$i]    = $entry_id;
    $i++;
    $template_variables[$i] = '{form_id}';
    $template_values[$i]    = $form_id;

    I suppose you could add any custom template variables there, below those lines.

    I hope that helps.


    MachForm Founder

    Posted 14 years ago #
  3. Trowar
    Member

    Thanks Yunair,

    I figured out what I was doing wrong. I added the code

    $template_variables[$i] = '{rvdate}';
    $template_values[$i] = $rvdate;
    $i++;

    and it didn't work. I realised I had to popluate $rvdate as Machform wasn't doing this for me.

    $rvdate = 'test';
    $template_variables[$i] = '{rvdate}';
    $template_values[$i] = $rvdate;
    $i++;

    So it turns out it was simple to do :)

    Many Thanks for your help.

    Posted 14 years ago #

RSS feed for this topic

Reply