0

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

0

try this code:

$resultRedirect->setPath('cms/index/index');

if you need to delay, use function sleep() of php

| improve this answer | |
0

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.

| improve this answer | |
0

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!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.