I'm using smarty and php for my website. There is some code which converts the data into json. I want to use that data in a smarty template. That data is a set of error messages and I want to display those messages in a assigned smarty template at desired ID. I'm not able to get that in smarty template. Actually what is happening is the error messages are displayed on a plain page instead in the desired tag. Following is my smarty and PHP code: Following is the smarty code where I want to display the error messages:
if $error_msg}<div class="error-info">{$error_msg.error_msgs}</div>{/if}
Now following is my PHP code:
<?php
if($request['form_submitted']=='yes') {
$ret = $objPracticeSheet->InsertPracticeSheet($request, $practice_sheet_error_messages);
if(!$ret) {
$error_msg = $objPracticeSheet->GetAllErrors();
$data = array();
$data['error_message'] = $error_msg['error_msgs'];
$data = json_encode($data);
echo $data;
die;
} else {
$data = array();
$data['success_message'] = "success";
$data = json_encode($data);
echo $data;
die;
}
} else {
$all_subjects = $objSubjectsTopicsQues->GetAllSubjectsHavingTopics();
$smarty->assign('all_subjects', $all_subjects);
$smarty->assign('sheet_type', 'practice');
$bread_crumbs_text = 'Add Practice Sheet';
$submit_value = 'Submit';
$cancel_value = 'Cancel';
$file_to_show = 'manage-practice-sheet.tpl';
}
$smarty->assign("op", $op);
$smarty->assign("query_string", $query_string);
$smarty->assign("bread_crumbs_text", $bread_crumbs_text);
$smarty->assign("submit_value", $submit_value);
$smarty->assign("cancel_value", $cancel_value);
$smarty->assign("error_msg", $error_msg);
$smarty->assign("file_to_show", $file_to_show);
/*$smarty->assign('create', '-active');
$smarty->assign("sub_menu_file", "epn-create-sub-menu.tpl");
$smarty->assign('practice_sheet', '-active');*/
$smarty->assign('practice_sheet', 'active');
$smarty->assign('prepare', 'selected');
$smarty->display("index.tpl");
?>
Can you help me in displaying the error messages json data in the above div? Thanks in advance. I'm also attaching the screenshot of the current output.