Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Offline
Re: Add the ability to alterate admin UI messages
Or try this:
...
public function sendMessage($event, $step)
{
send_script_response(announce(array('ERROR!', E_ERROR)));
exit;
}
...
Offline
Re: Add the ability to alterate admin UI messages
etc wrote #307741:
Then it’s probably not
async
. Check the posted data in browser console.
It is in async mode, but my custom message is overridden.
See the response in the console:
;
$(document).ready(function ()
{
$("#messagepane").html("<span class=\"messageflash error\" role=\"alert\" aria-live=\"assertive\"><span class=\"ui-icon ui-icon-alert\"></span> ERROR! <a class=\"close\" role=\"button\" title=\"Close\" aria-label=\"Close\" href=\"#close\">×</a></span>");
});;
;
$(document).ready(function ()
{
$("#messagepane").html("<span class=\"messageflash success\" role=\"alert\" aria-live=\"assertive\"><span class=\"ui-icon ui-icon-check\"></span> Page <strong>error_defa</strong> updated. <a class=\"close\" role=\"button\" title=\"Close\" aria-label=\"Close\" href=\"#close\">×</a></span>");
});;
var $html = $("<div>\n<section class=\"txp-details\" id=\"all_pages\" aria-labelledby=\"all_pages-label\">\n<h3 id=\"all_pages-label\">All pages</h3>\n\n<div role=\"group\"><ul class=\"switcher-list\"><li class=\"active\">\n<a href=\"?event=page&name=error_defa&_txp_token=c5db78b24de2a4042322ff89b8056790\">error_defa</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"error_defa\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=j&_txp_token=c5db78b24de2a4042322ff89b8056790\">j</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"j\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=jhffh&_txp_token=c5db78b24de2a4042322ff89b8056790\">jhffh</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"jhffh\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=jhgj&_txp_token=c5db78b24de2a4042322ff89b8056790\">jhgj</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"jhgj\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=jhgjh&_txp_token=c5db78b24de2a4042322ff89b8056790\">jhgjh</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"jhgjh\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=khgjg&_txp_token=c5db78b24de2a4042322ff89b8056790\">khgjg</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"khgjg\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=lo&_txp_token=c5db78b24de2a4042322ff89b8056790\">lo</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"lo\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=mo&_txp_token=c5db78b24de2a4042322ff89b8056790\">mo</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"mo\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=no&_txp_token=c5db78b24de2a4042322ff89b8056790\">no</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"no\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=salut&_txp_token=c5db78b24de2a4042322ff89b8056790\">salut</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"salut\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=yeo&_txp_token=c5db78b24de2a4042322ff89b8056790\">yeo</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"yeo\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=yes&_txp_token=c5db78b24de2a4042322ff89b8056790\">yes</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"yes\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li>\n<li>\n<a href=\"?event=page&name=Yop&_txp_token=c5db78b24de2a4042322ff89b8056790\">Yop</a>\n<form method=\"post\" action=\"index.php\" data-verify=\"Really delete?\"><button class=\"destroy\" type=\"submit\" title=\"Delete\" aria-label=\"Delete\"><span class=\"ui-icon ui-icon-close\">Delete</span></button>\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_delete\" />\n<input name=\"name\" type=\"hidden\" value=\"Yop\" />\n<input name=\"_txp_token\" type=\"hidden\" value=\"c5db78b24de2a4042322ff89b8056790\" />\n</form>\n</li></ul>\n</div>\n</section></div>");
$("#all_pages").replaceWith($html.find("#all_pages"));
var $html = $("<div>\n<div class=\"txp-form-field name\">\n<div class=\"txp-form-field-label\"><label for=\"new_page\">Page name</label></div>\n<div class=\"txp-form-field-value\">\n<input class=\"input-medium\" id=\"new_page\" name=\"newname\" type=\"text\" size=\"16\" required=\"required\" value=\"error_defa\" /></div>\n</div>\n<input name=\"name\" type=\"hidden\" value=\"error_defa\" />\n<input name=\"skin\" type=\"hidden\" value=\"b\" />\n<input name=\"event\" type=\"hidden\" value=\"page\" />\n<input name=\"step\" type=\"hidden\" value=\"page_save\" /></div>");
$("div.name").replaceWith($html.find("div.name"));
$("#new_page,input[name=name]").val("error_defa");
Last edited by NicolasGraph (2017-11-09 11:50:02)
Offline
Offline
Offline
Re: Add the ability to alterate admin UI messages
Now you should be able to inject your own message, try replacing exit
with return
again.
Offline
Re: Add the ability to alterate admin UI messages
etc wrote #307751:
Now you should be able to inject your own message, try replacing
exit
withreturn
again.
Thanks; my custom message is now prepended to the existing one and the error status is correctly alterated. Maybe it should come after the one generated by the core? No big deal.
Offline
Re: Add the ability to alterate admin UI messages
NicolasGraph wrote #307760:
Thanks; my custom message is now prepended to the existing one and the error status is correctly alterated. Maybe it should come after the one generated by the core? No big deal.
Messages are appended as they arrive. This can be tweaked, but needs some thinking first.
Offline
Re: Add the ability to alterate admin UI messages
Hi, I’m back in this thread because I would like to affect the Preferences tab related message on saving but I can’t; it is not in async mode. Anything I could do?
Thanks.
Offline