hi..
I have a form that sends and stores information in the database using JAJX method. Everything is fine and work is done. But after sending it to the database I want to send a variable to that page to display ... I did the following but it didn't work.
in my tpl file:
{__("product_brand")}
{__("sh_code")}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_cargo_weights.tpl"}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_product_types.tpl"}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_car_types.tpl"}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_origins.tpl"}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_destinations.tpl"}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_package_types.tpl"}
in control file:
use Tygh\Registry;
use Tygh\Ajax;
use Tygh\Tools\Url;
if (!defined(‘BOOTSTRAP’)) { die(‘Invalid Access’); }
if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {
if ($mode == ‘update’) {
if (defined(‘AJAX_REQUEST’)) {
$id= $_REQUEST[‘result_ids’];
$tracking_code = fn_update_freight_request($_REQUEST['freight_request_data'], $_REQUEST['freight_request_id']);
$val = $tracking_code['tracking_code'];
Registry::get('ajax')->assign("result", $val);
exit;
}
}
}
The following code can send the result to div with the result ID .. But I want it to be pop-up and the code will be displayed in a pop-up I designed ...
Registry::get('ajax')->assignHtml("$id", $val);
Please tips. thanks
- Put this part of code to the separate file
{$id}
- Include it in the file where the form is displayed
- Use the following code before exit in the controller (do not forget to correct file path)
Tygh::$app['view']->display('addons/your_addon/path_to_file/file.tpl');
It should solve your issue
- Put this part of code to the separate file
{$id}
- Include it in the file where the form is displayed
- Use the following code before exit in the controller (do not forget to correct file path)
Tygh::$app['view']->fetch('addons/your_addon/path_to_file/file.tpl');
It should solve your issue
Thank you dear friend..
Can you give me more explanation?
I didn't notice you wrote in the code above: "{$id}" but in your last code I don't see "{$id}". I got confused.
Do you mean something like that?
in form file: name: form.tpl:
{__("product_brand")}
{__("sh_code")}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_cargo_weights.tpl"}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_product_types.tpl"}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_car_types.tpl"}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_origins.tpl"}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_destinations.tpl"}
{include file="addons/vv_horn_changes/views/product_vendor/components/freight_request_assign_package_types.tpl"}
In the answer file: answer.tpl:
{$id}
in controller:
use Tygh\Registry;
use Tygh\Ajax;
use Tygh\Tools\Url;
if (!defined('BOOTSTRAP')) { die('Invalid Access'); }
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($mode == 'update') {
if (defined('AJAX_REQUEST')) {
$id= $_REQUEST['result_ids'];
$tracking_code = fn_update_freight_request($_REQUEST['freight_request_data'], $_REQUEST['freight_request_id']);
$val = $tracking_code['tracking_code'];
Registry::get('ajax')->assign("id", $val);
//your code
Tygh::$app['view']->fetch('addons/your_addon/path_to_file/file.tpl');
exit;
}
}
}
For example, create the following file
design/themes/responsive/templates/addons/my_changes/views/vv_freight_requests/answer.tpl
{$id}
To the end of tpl file add
{include file="addons/my_changes/views/vv_freight_requests/answer.tpl"}
Before calling exit in the vv_freight_requests controller add
Tygh::$app['view']->display('addons/my_changes/views/vv_freight_requests/answer.tpl');
For example, create the following file
design/themes/responsive/templates/addons/my_changes/views/vv_freight_requests/answer.tpl
{$id}
To the end of tpl file add
{include file="addons/my_changes/views/vv_freight_requests/answer.tpl"}
Before calling exit in the vv_freight_requests controller add
Tygh::$app['view']->display('addons/my_changes/views/vv_freight_requests/answer.tpl');
Thank you my dear friend..