2.0 Customisation

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
RedSpider
Posts: 36
Joined: Jan 30, 2015 2:47 pm

2.0 Customisation

Post by RedSpider »

Hi, upgraded from 1.3 to 2.0 and seem to be having some problems customising.

On 1.3 I used to be able to:
  • Customise the footer (eg remove the "Contact administrator for assistance").
  • Add custom logo at the top (g_logo_image doesn't seem to work anymore)
If anyone can let me know how to change these in 2.0 that would be awesome :)

SugarD-x
Posts: 5
Joined: May 15, 2011 2:53 pm

Re: 2.0 Customisation

Post by SugarD-x »

For the first one, look at ./core/htmlapi.php, and try adding your code before:

Code: Select all

function html_body_end()
As for customizing what is already there, I haven't figured that out myself yet.


In regards to your second question, it appears they removed it. I only see this logo set in the page footer, and centered on a re-authentication page for administrative access. I'm personally also trying to figure out where the code for starting the <body> tag went so I can make customizations too. In older versions it used this:

Code: Select all

function html_body_begin()
That has since changed, and I can't seem to find any code at all that does this within html_api.php.

Edit: I think I found where much of the code was hiding! There is another new file that handles the page output. It is called "layout_api.php", and is located in the ./core/ folder.

rkarmann
Posts: 66
Joined: Nov 24, 2017 5:00 am
Location: Lille, France

Re: 2.0 Customisation

Post by rkarmann »

Hi guys,

The best way to customize Mantis (even 2.X) is to build a Plugin. In fact, it is very easy once you've understand the plugin structure and events systems. This prevents from modifying to much core code.

1. Register your plugin, like in : https://www.mantisbt.org/docs/master-1. ... lding.html

2. Select the events to hook to customize specific locations in your Mantis : https://www.mantisbt.org/wiki/doku.php/ ... ins_events
[ The event you should hook to customize footer logo is : 'EVENT_LAYOUT_PAGE_FOOTER'. ]

3. Once the event is correctly hooked, you might be able to change bottom page logo using JQuery
In example, in an other page named 'logo_by_project.js' in plugin's /files directory:

In this example, I can switch the logo depending on wich project is selected. I hadded the class #mantis-logo to the IMG tag in layout_api.php (function layout_footer() ) between line 1130 and 1150.

Code: Select all

jQuery( document ).ready( function(){
# 1 -> get the project name from the dropdown list
	var project_name = $( "#dropdown-toggle" ).text();
# 2 -> PHP function trim() to delete any blank before and after the project_name
        var m_project_name = $.trim( project_name ) + "";
	var logo_url_project = "/mantisbt/images/" + m_project_name.toLowerCase() + ".png";
# 3 -> make sure it's LowerCase, and rename your custom logo with the project name (i. e. : myproject.png in yourmantisroot/images)
        $( "#mantis-logo" ).attr( 'src', logo_url_project );
        $( "#mantis-logo" ).attr( 'alt', '' );
});
4. In the function that is hooked to the FOOTER event, include the script:

Code: Select all

function footer() {
		echo '<script src="' . plugin_file( "logo_by_project.js" ) . '"></script>';
	}
Make sure that the JS file your calling is in the /files plugin's directory.

5. Install your plugin, and test it.

Hope you'll find this helpful :lol:
Currently working on a wiki-based plugin for MantisBT 2.X. If you'd like to test it, contact me or see the plugin section.

Post Reply