XF 2.0 Show message and then redirect

CMTV

Well-known member
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.
 
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.
 
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:
 
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:
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.
I was curious if this should work by now?

I tried to display the "Post new thread" button on the forum index to guests.
Once logged in, they should be redirected to the popup that lists all the nodes:

forum_overview_wrapper:
Code:
        <xf:button href="{{ link('forums/create-thread') }}" class="button--cta" icon="write" overlay="true" data-follow-redirects="true" data-force-flash-message="true">
            {{ phrase('post_thread...') }}
        </xf:button>

..but instead the user is redirected to the index instead of the overlay.
 
Top Bottom