Writing a plugin that removes and moves elements

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
mcmo
Posts: 11
Joined: 18 Oct 2016, 07:04

Writing a plugin that removes and moves elements

Post by mcmo »

Hi All

I am trying to figure out the best way to customise MantisBT; I have been asked to hide some fields, change the displayed value of some others (like removing the parent project name in the product version fields selectors) and moving custom fields into the standard fields when reporting, editing...
So far, I have created a plugin that creates some jQuery code that runs when the initial document is ready and does the changes described above.
I could not use only PHP code as there is no event set in the proper places to help achieve my targets.

I do wonder whether there would be a better way by executing my jQuery changes on the server and not on the client machine; I am that much happy to let some clever users block the automatic changes done by JQuery by debugging the application in Chrome (for instance).
I tried to change the DOM document in PHP using a plugin that would run when the document is almost ready. But that did not work. certainly because the DOM document did not contain anything when the plugin executes.
I wonder whether using the output buffer would be solution.
Roughly the plugin would run ob_start at the very beginning of the page creation
then at the end it would use ob_get_contents to return the contents of the buffer (cf. http://php.net/manual/en/function.ob-get-contents.php)
this would be loaded into a DOM document and then I could apply the same manipulations as in the Jquery code. all of those instructions on the server.
and the DOM document would be echoed to finally produce the page.

Would someone have a better/simpler suggestion?
Marc
--------------------------------
Mantis: 2.1.0
PHP: 5.5.9
SQL: MySQL 5.7.16
OS: Ubuntu Linux 14.04.3
Post Reply