I want to redirect my view to the homepage after data submitted in a custom form
$resultRedirect->setPath('//');
This code leads to redirection, for now, please help
Also is it possible to get a delay of 5-10 sec in redirection
I want to redirect my view to the homepage after data submitted in a custom form
$resultRedirect->setPath('//');
This code leads to redirection, for now, please help
Also is it possible to get a delay of 5-10 sec in redirection
try this code:
$resultRedirect->setPath('cms/index/index');
if you need to delay, use function sleep() of php
You can directly use below code in Action controller
$this->_redirect('cms/index/index');
For delay in redirect, you can use sleep(5);
Please let me know if you find any difficulty.
There is a best example for redirect page after some time is customer logout.
You can use below code to redirect specific page.
$resultRedirect->setPath('Your redirect path');
For delay logic, you have to use the below script.
<script>
require([
"jquery",
"mage/mage"
], function($){
$($.mage.redirect("<?= $block->escapeJs($block->escapeUrl($block->getUrl())) ?>", "assign", 5000));
});
</script>
Note: Above code is not tested i have just share logic. you have to change or apply logic as per your requirement.
I hope it helps!