I’ve a smarty template code as follows and I want to write the smarty template data line by line into a text file. For this purpose I’ve to insert a newline at the end of each record(i.e. after the value $user_test_result.test_result_data.total_obtained_marks). How should this be achieved? Please help me out to resolve this issue. Thanks in Advance.
{if $all_user_test_result}{assign var='sr_no' value=1}{foreach from=$all_user_test_result item=user_test_result key=key}{if $key!='sort_user_name' && $key!='sort_total_obtained_marks' && $key!='sort_no_correct_answers' && $key!='sort_no_wrong_answers' && $key!='sort_no_skipped_questions'}{$sr_no};{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_user_data.user_name};{else}{$user_test_result.test_user_data.user_name};{/if}{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_user_data.test_user_time_used};{else}--{/if}{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_result_data.no_correct_answers};{else}-{/if}{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_result_data.no_wrong_answers};{else}-{/if}{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_result_data.no_skipped_questions};{else}-{/if}{if $user_test_result.test_user_data.user_status=='Attempted'}{$user_test_result.test_result_data.total_obtained_marks};{else}-{/if}{/if}{assign var='sr_no' value=$sr_no+1}{/foreach}{else}Result not found{/if}
There should be new line character (“\n”) with smarty tags around it placed after the value
$user_test_result.test_result_data.total_obtained_markslike this {“\n”}. You’ll get the desired result.