Mantis BT CustomContent plugin - add custom PHP, HTML, CSS and JS files in Mantis HTML Layout A lightweight plugin for Mantis Bug Tracker 2.x that allows to insert custom PHP, HTML, CSS and JS content within the default MantisBT HTML theme layout

Mantis Bug Tracker - Abilitare e disabilitare le notifiche via E-Mail

If you're reading this I guess you already know Mantis Bug Tracker, also known as MantisBT,  one of the best open source issue trackers available on the web since eighteen (!) years ago and still rocking its way, providing a delicate balance between simplicity and power. If you don't use bug tracking software, I strongly suggest to try it at least once: once you start using it, there's an high chance that you will never go back!

Just to be clear: NO, I'm not working for them and I'm not part of the development team, neither I have got a penny for writing this: I'm just an old & fond MantisBT user since 2001 and I happen to really like the software :)

Anyway, if you stumbled upon here there's a high chance that you want to find a way to insert some custom content - such as PHP, HTML, JS, CSS, images and so on - within the default MantisBT template layout, which is not an easy task - unless you want to hack the Mantis core libraries, thus being unable to upgrade it anymore.

Since the release of MantisBT 2.x, which featured a complete rebuild of the layout engine, the Mantis page HTML structure is created dinamically by the /core/layout_api.php  file, thus making the layout HTML modding even more painful than before. Luckily enough, there are two global parameters that can be used to include files at the top and at the bottom of the page.

They are explained - together with all the other options - within the MantisBT Admin Guide txt file, which is part of the MantisBT official docs:

That's great, isn't it? Except that these global variables aren't working since months, as we can read in the MantisBT bug #22098. In short words, there's currently no way to add custom content (or include custom files) in a MantisBT default installation.

Introducing CustomContent Plugin

For this very reason I developed the CustomContent MantisBT plugin, wich can be used to include custom HTML, PHP, JS or CSS content within the MantisBT HTML layout structure. As I said before, it has been originally developed to provide a workaround for the MantisBT bug #22098, based upon the fact that the $g_top_include_page and $g_bottom_include_page global variables are not supported / not working anymore (as of MantisBT 2.16.0, at least).

Installation

Installing the CustomContent plugin is very simple, you just have to follow these steps:

  • Download the CustomContent GitHub package as a single zip file & unzip it in the /mantisbt/plugins/ folder of your current MantisBT installation.
  • Rename the resulting folder to /CustomContent/ so that the main plugin PHP file will have the following path: /mantisbt/plugins/CustomContent/CustomContent.php.
  • While logged into your Mantis installation as an administrator, go to Manage > Manage Plugins.
  • In the Available Plugins list, you'll find the CustomContent plugin.

Mantis BT CustomContent plugin - add custom PHP, HTML, CSS and JS files in Mantis HTML Layout

  • Click the Install button to install the plugin into your current MantisBT environment.

Mantis BT CustomContent plugin - add custom PHP, HTML, CSS and JS files in Mantis HTML Layout

  • Navigate to the /mantisbt/plugins/CustomContent/inc folder and edit/modify the content files accordingly (see Usage below).
  • Open the /mantisbt/config/config_inc.php file (the MantisBT configuration file) and add the following lines:
Feel free to change the folders, paths & filenames accordingly to your needs.

Usage

You can use the included files just any other PHP file: you can include PHP code, <script><link> and <style> elements to link external JS and CSS files or include internal code, images, text and so on.

Supported Versions

  • MantisBT 1.x - not supported
  • MantisBT 2.x - supported

Acknowledgements

A huge thanks to Xenos, to his MyKingCustomPlugin and to all the crew of the MantisBT bug #22098 who strongly inspired me to write this plugin.

Official Resources

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

3 Comments on “Mantis BT CustomContent plugin - add custom PHP, HTML, CSS and JS files in Mantis HTML Layout A lightweight plugin for Mantis Bug Tracker 2.x that allows to insert custom PHP, HTML, CSS and JS content within the default MantisBT HTML theme layout

  1. The plugin is giving me the folowing error

    APPLICATION WARNING #100

    Configuration option “custom_head_file” not found. (in ‘C:\Server2\www\FVHD2\core\config_api.php’ line 180)

    Please use the “Back” button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

    1. Sam,
      I’m getting the same error
      APPLICATION WARNING #100

      Configuration option “custom_page_footer_file” not found. (in ‘C:\xampp\htdocs\mantis\core\config_api.php’ line 191)

      Please use the “Back” button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.