percentage in emails templates

39 views
Skip to first unread message

Mike

unread,
Nov 30, 2012, 5:15:10 AM11/30/12
to agileb...@googlegroups.com
Hi there,

I'm getting the data from the vars correctly but the percentages are still there, ie: %data%
Just wondering if anyone else had this?

for email templates here's a good link:
http://www.agileco.com/forum/showthread.php?t=1143&highlight=mail

01-27-2006, 10:02 AM
AgileBill Guru!
 
Join Date: Dec 2004
Posts: 1,218
Default

Okay real quickly...

As admin pointed out ... %sql1_domain_name%.%sql1_domain_tld% could be placed in your template if your custom SQL1 contains the appropriate query. Here's an overview of how to go about it, pretty much as outlined in the documentation located at: http://www.agilebill.com/EmailTemplateCoding?v=gfq

To add such things as %var_variable%, you will first need perform an SQL query. This can be done a number of ways, but is easiest with performing associative queries using the custom SQL fields in your templates. For instance:

In this case **assume** %SQL1% contains the account number (account_id) we could do:

SELECT * FROM %DB_PREFIX%account WHERE id = %SQL1%

Your template will now provide you with the matching account table array which you can call in your template using something like:

%sql1_first_name% %sql1_middle_name% %sql1_last_name%
%sql1_company% ...

Easy, right?

I think the account info is available in all templates anyway, but it's just an example.

You can also use the custom SQL fields to do associated, recursive and join lookups. That's a bit more complex.

Then, there is also another approach:

Depending on which template you need to modify and what you intend to print to it, you can also modify the code in the particular module that actually calls the email template function.

That function looks something like:

$mail->send('this->template',$account_id,$SQL1,$SQL2,$SQL3);

So let's say you wanted to assign values to $SQL1, 2 or 3. You would need to perform your query and assign your variables before calling the email function.

In that instance, if you assigned a variable to $SQL2 for instance and use it to do a lookup when generating your invoices. Nice eh?

etc.

Hopefully I didn't miss anything.

Mike

unread,
Nov 30, 2012, 5:27:23 AM11/30/12
to agileb...@googlegroups.com
I found a file which looks like handles email vars:
AB/modules/email_template/email_template.inc.php

I'm still trying to figure out debugging this beast.


        ### Remove any unparsed vars from the body text and html: 
        if(!empty($E['body_html']) && preg_match('/%/',$E['body_html']))
        @$E['body_html'] = preg_replace("/%[a-zA-Z0-9_]{1,}%/", '', $E['body_html']);
        if(!empty($E['body_text']) && preg_match("/%/",$E['body_text']))
        @$E['body_text'] = preg_replace("/%[a-zA-Z0-9_]{1,}%/", '', $E['body_text']);           
Reply all
Reply to author
Forward
0 new messages