Hi !
I would like to render some field in the templateparser by my own.
For all “logical” fields (yes/no, etc…), I can do the trick correctly.
But for the string value, i cannot : the string is always shown “as it” despite of my code…
I have this code in the templateparser :
if($name === ‘aos_quotes_fw_precisionpapier_c’){
if (empty($value)) {
$value = “”;
} else {
$string = str_replace("$$name", $value, $string);
$value = 'Précision sur la couleur et le grammage : : ’ . $string . 'PAYSAGE ';
}}
If you take a look, you can see i have used the line for string (at the bottom of the parser in the file) to add the file content.
Unfortunatly, it seems that the last piece of code rendering the string is taking the place of my code in the rendering.
My question is then : for a specific string var, can I add a specific code to render it ? If so, how to ?
Thanks for the help
Xavier
I have a logical mistake in my code : i was assuming the “string” code was for the string vars !
This works fine like this :
if($name === ‘aos_quotes_fw_precisionpapier_c’){
if (!empty($value)) {
$valeur = $value;
$value = 'Précision sur la couleur et le grammage : : ’ . $valeur . ‘’;
} else {
$value = “”;
}}
For a field, i can add some rendering option in “simple” html (formating the text).
That’s fine. But if i want to build completely the structure with for example a “table”, it does not work ?
For example (not the good code but just for the example
The table is not then added to the pdf results : normal ? If so, is there a way to add the “structure” in the templateparser ?
The goal is to have a complete build of the pdf in the parser php : i just add the field in the pdf template in SuiteCrm and i build all in my own parser.php.
so, after line 153 (orignal file ) and before the line 156.
The fields are included as “usual” in the parser php as this is done (found information on other post on the forum).
The file modified is in modules/AOS_PDF_Templates/templateParser.php
Is this help to explain why i dont get the table or div rendered if included in my code ?
Thanks,
Xavier
Is there a way to find a person here able to tell me why the “table” and “div” are not rendered if they are called in the templateparser.php ?
Again, the goal is to create the structure directly in the parser : i can show or hide text information when parsed in this file but if there is a lot of information not used (so, not shown in the final file generated), i have a lot of empty space. If i can generate the table directly in the file, i can then generate a more compact file to print.
Thanks again to PGR and thanks to any other person able to give me some information
Xavier
This open a lot of possibility then !
Maybe I can ask more : i have 3 custom fields for example (in fact i have many many more !).
Can i then put a condition in the templateparser with something like : if the field1 is not empty, render the field1 and field2 and field3, otherwise do nothing ?
So, i think to :
Table - Title of the table is the field 1
Column1 : Field2
Column3 : Field3
If the field 1 exist and is not empty, render the full table with field1+2+3.
My question is more then : when the parser.php is called, it is read one time for each field no ? Then, i cannot put a condition on several fields at the same time ?
Maybe you have already found this before on some other question ?
Again and again, Thank you so much for your help for this so stupid issue of px !
Xavier
Ok, i see how to : as i have the full document return as “string” as the end of the file, i have to construct a full variable in the code storing the exact build i want (not sure to be clear in my explanation
I’m going to check all this : much better now with this simple “use px” !
If somebody is interrested, i will come back to give you the results
Bye !
Xavier
Back !
I have a little question more for the fields parsing in this file.
When i use some custom fields, i have a field in the template with a name like : “aos_xxxxxxxx…c”.
I can parse them easily with and choose how to show them.
Now, if i use the field already included in the crm, like for example “$billing_account_name”, even if i had a formating in my code with :
if ($name === 'billing_account_name'){
//my formating code here
}
The code is never read…
My question is : for the core fields, how i can parse them to have the same behavior than my custom fields ?
I have checked the parser but i dont see where it is done (there should be a code somewhere but i cant find it…).
It’s probably account_billing_account_name or accounts_billing_account_name
The $repl_array is prepared in the cycle before that one where you are. You can use print_r($repl_array) or var_dump($repl_array) as debugging tools to see everything that’s permissible.
I have tried the print_r and var_dump. Unfortunately, i’m not enough good to get this working (nothing on screen or in console or in the generated pdf… I have also tried to assign the result to the var $string to see if I can get the result in the pdf, but all is “blank”).
What is strange in what you say about account_billing_account_name is the name have been retrieved from the dropdown in the pdf template constructor in SuiteCrm.
If i use the field, it works : i can get the value in the result.
But if i add my formating condition, the condition is never read : how the field could works if not formated but not read ? I dont get this…
To be completely clear :
I have in the editor for the PDF template the field called :
" Société / Compte : $billing_account_name"
The field show me correctly the field value (so, this is correctly called in the pdf)
With my condition (given before in my previous post), the condition is never read (i have put another condition to fill in both cases empty or not empty and i get nothing at all).
How this field could be “read” with this field name if this not corresponding to the name in the condition ?? This is what i dont get…
If you could give me the example code to put in my parser to see all the tab (again : nothing on screen, nothing on pdf, nothing on console… and i have changed your example from $repl_array to the name in the file as $repl_arr…
Thanks again for all the time you spend here to help me
Xavier
You need to look at the code and see what it’s doing.
The parse_template function does this:
it receives an array of beans (normally containing only one, I expect)
for each of those beans, it will run parse_template_bean for the bean itself, and then iterate each relate field, get the corresponding bean, and also run parse_template_bean on that
So parse_template_bean will actually be run often, each time replacing variables from different modules.
The parse_template_bean function does this:
runs a 1st cycle for each field in the module, building a $repl_array which is an array listing each potential variable name and its replacement value. The generic format will be module name (or relate field name), followed by an underscore, followed by the field name:
For the accounts module, the parse_template_bean will successively be called with a $key of:
accounts
modified_by_name
created_by_name
assigned_user_id
assigned_user_name
parent_name
campaign_name
Bottom line, I think you just have a confusion with field names… it’s not $billing_account_name, it’s a bunch of $billing_address_... fields, seen here in my debugger:
Thanks again PGR
I will try all this (really, thanks for your explanation !) and will come back with other questions if needed.
Just one question : what do you use to get these vars shown ? You work locally ?
This is what i miss : i dont know how to show the vars and somewhere, i work as a “blind”…
Thanks PGR, i repeat it again, but you help me a lot
To try to find the “correct” string, i add what you suggest before the var name : “account_…” (no success) and “accounts_…” (no success). I also try with contact_… just in case (no success).
So, to try to find the correct var names, i have tried this : at the bottom of the file, i have replaced the line like this :
I can see then the “name” of the vars instead of the content.
The thing is : i still see the var with the name “billing_account_name”.
If i dont “put you on the nerve” with my stupid questions, i will be very gratefull if you can help me some more on these 2 last questions…
I understand what you wrote before with the key, but dont get how to get the correct name to make my test and format as i want the core vars… If i understand you well, it should be “accounts_billing_account_name” but i should miss something again in your explanation.
Can you try on your side if this is not to much asked and if you have time for this to see what i’m doing wrong ? I’m obviously doing the wrong thing but i dont see what…