Jump to content

Can you add smarty codes to HTML header or Footer?


Recommended Posts

Hi Team,

I know you can add smarty code in emails when you send then, but am I able to add smarty code in the HTML Header or Footer in mail configuration?

For contact, I have a HTML header and want to add the client name to the header. This works in the main body of a response, but does not seem to work when smarty us placed in header or footer.

Hope this makes sense!

Thanks,

Brad

Link to comment
Share on other sites

17 hours ago, SaneChoiceLtd said:

I know you can add smarty code in emails when you send then, but am I able to add smarty code in the HTML Header or Footer in mail configuration?

yes - though really it depends on what you mean by code.... some Smarty variables would be available (many are used by default), but Smarty coding would be constrained by the Smarty Security Policy - as it would be in the main body.

17 hours ago, SaneChoiceLtd said:

For contact, I have a HTML header and want to add the client name to the header. This works in the main body of a response, but does not seem to work when smarty us placed in header or footer.

if I add the client name to the footer (editing client email footer content in general settings -> mail), it works for me...

                                    <table border="0" cellpadding="0" cellspacing="0" width="100%" id="templateFooter">
                                        <tr>
                                            <td valign="top" class="footerContent">
                                                 <a href="{$company_domain}">visit our website</a>
                                                <span class="hide-mobile"> | </span>
                                                <a href="{$whmcs_url}">log in to your account</a>
                                                <span class="hide-mobile"> | </span>
                                                <a href="{$whmcs_url}submitticket.php">get support</a> <br />
                                                Copyright © {$company_name}, All rights reserved.<br />
                                                Client Name: {$client_name}
                                            </td>
                                        </tr>
                                    </table>

hzfcaw1.png

that should work on both generic and ticket support emails.

Link to comment
Share on other sites

Thanks Brian!

 I am ashamed to admit (head hung down in shame!) that I was using an invalid variable so that was why it was not working in the HTML Header.  🙂 

What I am now really after is a smarty IF statement to work out whether the person is a client or a guest.  If the person is a client, I want to display one thing, if the person is a guest (i.e. not a client) I want to display something different. 

I have tried to search this but I cannot find the syntax/code to do this.  I am sure its something like the below but I don't know the variable for client and what syntax is used to decide if the person is a client. 

{if $client_exists eq "Yes"}
Sales only operates Monday-Friday 9am-5pm
{else}
Your ticket has been received and will be answered shortly
{/if}

Any ideas on this one?

Brad

Link to comment
Share on other sites

Hi Brian,

Thanks to your help, I have created a really nice email template that customise based on client verses guest.  Really useful.

However, I have two more questions to help me be more self sufficient and stop bugging you. 

  1. Where can I find a complete set of smarty tags that can be used in all emails?  Checked the WHMCS docs but not sure I am looking in the right place. 
  2. New Functionality: In an email that gets sent to a client, if it is an email being sent which is an invoice or financial related, is there a way to detect?  Logic something like:
{if $invoicerelated}
Show a HTML section in FOOTER to point clients to download area
{else}
Do not show this section
{/if}

Any ideas on this one?

Thanks,

Brad

Link to comment
Share on other sites

HI Brad,

4 hours ago, SaneChoiceLtd said:

Thanks to your help, I have created a really nice email template that customise based on client verses guest.  Really useful.

that's good to hear. thanks.png

4 hours ago, SaneChoiceLtd said:

Where can I find a complete set of smarty tags that can be used in all emails?

AFAIK, they aren't listed anywhere in the docs.... there would have been a thread started 5+ years ago where a user listed them as they were then, but there will have been new templates and any multitude of changes to the email templates since then so as to make that list effectively worthless.

4 hours ago, SaneChoiceLtd said:

Checked the WHMCS docs but not sure I am looking in the right place. 

I suspect the WHMCS docs writer(s) wouldn't touch producing such a list as it would need to be maintained and potentially updated for each release - it takes them forever to attempt to keep the Class docs updated (still waiting for 8.1 and there are omissions and errors in the v8.0 class docs).

the simplest way to get a list of variables available to a template would be to add {debug} to the email template you want to test; send yourself (e.g test account) the relevant email; view the email from the emails tab of the client profile and it should open a debug window listing most of the Smarty variables available to the template.... remember to remove {debug} from the email template when you've finished.

4 hours ago, SaneChoiceLtd said:

New Functionality: In an email that gets sent to a client, if it is an email being sent which is an invoice or financial related, is there a way to detect?

I would just use a variation of the $client_id method above and find a variable that is unique to a given set of templates, so for invoices, I would have assumed that $invoice_id should only exist on invoice emails..

{if $invoice_id}Show a HTML section in FOOTER to point clients to download area{/if}

similarly, I think $service_id should exist if it's a product template; $ticket_id if it's a support template etc.

if you really had to, you could write a hook to determine the email type and pass that value back to the email template for use in an if statement - but I would think, by hook or by crook, you should be able to determine what it is from existing Smarty values without resorting to external coding.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated