dokuwiki-plugin-bureaucracy
dokuwiki-plugin-bureaucracy copied to clipboard
Redirect to new page after submit
Is it possible to redirect automatic instead of showing the link to the page? That would be really great!
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?
- 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
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?
I don't like presentation after submit, +1 for this feature ! ;)
Hello,
Someone figured out how can we redirect after submit ?
BR.
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):
- 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
- include the function plugin (https://www.dokuwiki.org/plugin:function) in the thank you page and use some redirection functionality in there
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).
Still active?
<form>
...
Thanks [[:my:thankyou:page]]
...
</form>
Would be lovely.
<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
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;
@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) {
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...
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.