dokuwiki-plugin-bureaucracy icon indicating copy to clipboard operation
dokuwiki-plugin-bureaucracy copied to clipboard

Redirect to new page after submit

Open Wikunia opened this issue 12 years ago • 13 comments

Is it possible to redirect automatic instead of showing the link to the page? That would be really great!

Wikunia avatar Jul 25 '13 09:07 Wikunia

Normal redirects aren't possible from the syntax plugin (where code code is located).

A workaround is something with javascript....

... something to store $MSG to session...

echo '<script type="text/javascript">';
echo 'window.location = "' . wl($pageid,'',true) . '"';
echo '</script>';

Development questions: Is a javascript redirect ok? Do the webbug and iframes for indexing and rendering of the new pages need much time?

Klap-in avatar Jan 10 '14 10:01 Klap-in

  • JavaScript would be okay, but handling this earlier would be better for the next reasons
  • msg() is stored in the session automatically, but since your javascript runs after a page has been displayed (including messages) they are cleared already when you redirect to the next page
  • the webbug should be fine (it will continue to run even if the user aborted the request)
  • the iframes will definitely need some time, but since this request is for when the result is a single page only it is not needed at all because the user will trigger the processing himself after the redirect

splitbrain avatar Jan 10 '14 11:01 splitbrain

Handling the post of the form earlier, means that it should be moved to an action component. Is there a way to have access from the action component to the fields as parsed by the handle() of syntax_plugin_bureaucracy?

Klap-in avatar Jan 10 '14 11:01 Klap-in

I don't like presentation after submit, +1 for this feature ! ;)

LeDistordu avatar Jun 08 '15 09:06 LeDistordu

Hello,

Someone figured out how can we redirect after submit ?

BR.

NadaBrisville avatar Jul 07 '15 10:07 NadaBrisville

Hi, I haven't tried to use it for redirecting purposes, but it might work (if redirection at this point outside of header is working in dokuwiki):

  1. compare fork: https://github.com/elaratain/dokuwiki-plugin-bureaucracy there are essentially two lines which enable you to use wiki syntax on thank you page
  2. include the function plugin (https://www.dokuwiki.org/plugin:function) in the thank you page and use some redirection functionality in there

elaratain avatar Jul 07 '15 11:07 elaratain

A simple hack allows page redirection using the Thankyou field (will not survive updates). https://www.dokuwiki.org/plugin:bureaucracy#customise_the_thankyou_message

That doesn't allow auto redirect - it only adds a page link to the Thankyou message. I did (briefly) look at extending the hack so that it would support the Dokuwiki <php> code tags so that php could be used to auto redirect - but that would require using htmlspecialchars_decode() instead of the simpler p_render (and likely create more problems than it solves - though it could, possibly, be part of a way to use jquery(location).attr('href', '$somewhere') instead of the standard Thankyou message).

Would the webbug method allow redirecting to a page determined by a variable created in the Bureaucracy form? I ask because while the ability to auto redirect would be useful - it would be far more useful if the redirection could be configured to use a variable created by the form (e.g. the form creates a new page billy_gates and the redirection loads the newly created page).

SFITCS avatar Jan 14 '16 02:01 SFITCS

Still active?

<form>
...
Thanks [[:my:thankyou:page]] 

...
</form>

Would be lovely.

MvErven avatar Sep 11 '17 09:09 MvErven

<form>
...
Thanks [[:my:thankyou:page]] 

...
</form>

yes, this would be nice. Why? Using -bureaucracy forms now in a mobile phone will generate a final rezult like this:

Success message !
  NameSpace
             NameSpace
                      NameSpace
                              Nam
                                    e
                                    S
                                    p
                                    a
                                    ce
                                         F
                                         i
                                         l
                                         e    

Floffyko avatar Nov 09 '18 16:11 Floffyko

This is a hack to redirect you to the newly created page (the first if several): Change line 365 in actiontemplate.php to $html = '<meta http-equiv="refresh" content="0; URL=' . "'" . 'doku.php?id=' . ($pages[0]) . "'" . '" />'; right before return $html;

andjar avatar May 04 '20 22:05 andjar

@splitbrain Expanding on @andjar's hack, would something like this cause any serious issues?

--- a/helper/actiontemplate.php
+++ b/helper/actiontemplate.php
@@ -329,12 +329,18 @@ class helper_plugin_bureaucracy_actiontemplate extends helper_plugin_bureaucracy
         global $ID;
         $backupID = $ID;
 
-        $html = "<p>$thanks</p>";
-
         // Build result tree
         $pages = array_keys($this->targetpages);
         usort($pages, array($this, '_sorttargetpages'));
 
+        if ($thanks == '__redirect__') {
+            return '<meta http-equiv="refresh" content="0; URL=?id=' . $pages[0] . '" />';
+        } else if ($thanks == '__redirect_edit__') {
+            return '<meta http-equiv="refresh" content="0; URL=?id=' . $pages[0] . '&do=edit" />';
+        }
+
+        $html = "<p>$thanks</p>";
+
         $data = array();
         $last_folder = array();
         foreach ($pages as $ID) {

fschrempf avatar Jan 08 '21 19:01 fschrempf

I would love to see something like this in place. I plan on doing this in my own installation but would like to have it survive updates...

elgiad007 avatar Apr 28 '22 18:04 elgiad007

return '<meta http-equiv="refresh" content="0; URL=?id=' . $pages[0] . '" />';
return '<meta http-equiv="refresh" content="0; URL=?id=' . $pages[0] . '&do=edit" />';

Instead of creating the URL yourself, @fschrempf, you might be able to use the built in function wl() - untested code follows:

return '<meta http-equiv="refresh" content="0; URL=' . wl($pages[0]) . '" />';
return '<meta http-equiv="refresh" content="0; URL=' . wl($pages[0], 'do=edit') . '" />';

That will cope with whatever slash and pretty URL configurations the installation has set.

iainhallam avatar Jul 05 '22 00:07 iainhallam