• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 Show message and then redirect

#1
I have added a custom button to account_detais template:
PHP:
<xf:button overlay="true" href="{{ link('account/reloadSkinHead') }}" class="button--link">{{ phrase('minecraftskins_account_reload_skin') }}</xf:button>
In reloadSkinHead action I want to display message that skin reload is complete and then reload current page.

I am using this code to achieve this:
PHP:
...
return $this->redirect($this->buildLink('account/account-details'), \XF::phrase('minecraftskins_account_reload_skin_success'));
The second argument of redirect method is message.

Everything works fine and I see "complete" message. The problem is that it opens a popup with reloaded "account-details" page. But I need to display message and reload page...

Popup is showing because of overlay="true" attribute. If I remove this attribute then page is correctly reloading. But in this case my "complete" message is not showing.
 

Chris D

XenForo developer
Staff member
#4
As well as the data-follow-redirects attribute above, if you also add data-force-flash-message="true" this won't work right now, but we'll add support for it in the next release.
 

HQCoder

Formerly dev.vnn
#5
I found it at line 450 of XF\Pub\Controller\Thread
return $this->redirect($this->buildLink('posts', $lastpost), $confirmation);

Code:
$this->getThreadRepo()->markThreadReadByVisitor($thread);
            $confirmation = \XF::phrase('your_message_has_been_posted');

            if ($post->canView())
            {
                return $this->redirect($this->buildLink('posts', $post), $confirmation);
            }
            else
            {
                return $this->redirect($this->buildLink('threads', $thread, ['pending_approval' => 1]), $confirmation);
            }

:unsure::unsure::unsure:But it doesn't seem working :unsure::unsure:
 
#6
As well as the data-follow-redirects attribute above, if you also add data-force-flash-message="true" this won't work right now, but we'll add support for it in the next release.
Please, upgrade it! It's not work when no-overlay.
 
Last edited: