Results 1 to 6 of 6

Thread: If in templates

  1. #1
    Join Date
    Mar 2009
    Posts
    9

    Default If in templates

    I want to display certain parts of a template only in certain cases. The template (PlainTemplate, good_template, bad_template) could look like that:

    Code:
    $mesg
    
    You received This Message from:
    Name: $realname
    Phone: $phone
    {if $company}Company: $company{/if $company}
    Is there a way I can achieve that? As Russel wrote at the end of this older post, templates can be a PHP file. But I do not know, how I can access a session variable in the php template, which is parsed with fopen. Right?!

    Any help is very appreciated. I guess this is a quite common feature request, but I could not find any solutions around. Thanks!

    Ludwig

    LULINE webdesign & development

  2. #2
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: If in templates

    Hi,

    There are two ways to achieve what you're asking:
    1. Write a PHP script that outputs the HTML you want, using PHP features such as "if".
    2. Use our Advanced Templates Feature.
    #1 requires you to use tell FormMail what fields you want placed in the PHP session:
    http://www.tectite.com/fmdoc/session_access.php

    and then your PHP script can access those fields in the session.

    You'll need some experience with programming to get this done with PHP.

    #2 is very simple to use, but requires you to purchase our FormMail Computation Module (which is currently only available as a source-code license at US$245).
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  3. #3
    Join Date
    Mar 2009
    Posts
    9

    Default Re: If in templates

    Russel, thanks for your help.

    I have a follow up question to the first solution. Let's say I specify a template for email.
    Code:
    <input type="hidden" name="mail_options" value="PlainTemplate=sample.php">
    Is that working? Sample.php will be parsed by fopen(), so I can not access php variables within that file, right? Can you tell me, how to access session variables in a mail template?

    Thanks again,
    Ludwig

  4. #4
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: If in templates

    Hi,

    Yes, the template is opened by FormMail (but, because it's PHP it's executed by the server) and the PHP session ID is passed as a parameter.

    You need to open the session:
    PHP Code:
    session_start(); 
    then you can access the session vars normally:
    PHP Code:
    echo $_SESSION["varname"]; 
    If you're not a PHP programmer, you may need detailed assistance with this.

    If you are, it's very straightforward.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  5. #5
    Join Date
    Mar 2009
    Posts
    9

    Default Re: If in templates

    Thanks again, Russell. We forgot the session_start(); Now we can access the session variables. Well, there is one more issue:

    It turned out, that the first test-mail that was sent with our php mail tempalte was empty. The second contained the information that was submitted the first time. And guess what, the third email contained the information that was submitted for the second mail.

    I conclude, that the posted information is stored in session variables after the the mail template has been opened?

    How can I access the just-sent session variables in the mail template?
    I appreciate all your help!

  6. #6
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: If in templates

    Hi,

    That doesn't sound right.

    I recommend you clear cookies and browser cache, and try a very controlled test.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 19-Apr-2006, 02:46 AM
  2. seperate templates
    By j2o in forum Community Support
    Replies: 0
    Last Post: 14-Mar-2006, 02:51 PM
  3. can't get good or bad templates to work...
    By skmember in forum FormMail Subscription Support
    Replies: 2
    Last Post: 04-Sep-2005, 10:14 PM
  4. php includes not showing up in good/bad templates
    By snodart in forum FormMail Subscription Support
    Replies: 2
    Last Post: 02-Apr-2005, 09:12 AM
  5. New Server - Templates sent as plain text
    By Anubis in forum FormMail Subscription Support
    Replies: 10
    Last Post: 19-Jan-2005, 10:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •