Page 1 of 1
PHP Fatal error: Call to undefined function html_page_top()
Posted: 13 Dec 2017, 20:41
by ShadowKatmandu
I am getting a PHP Fatal error: Call to undefined function html_page_top(). I am using MantisBT 2.8. Here is my code:
Code: Select all
require_once( '../../../core.php' ); // This is in a plugin, so this is where core.php is found for me
require_api( 'access_api.php' );
require_api( 'authentication_api.php' );
require_api( 'category_api.php' );
require_api( 'compress_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
require_api( 'current_user_api.php' );
require_api( 'gpc_api.php' );
require_api( 'helper_api.php' );
require_api( 'html_api.php' );
require_api( 'lang_api.php' );
require_api( 'print_api.php' );
require_api( 'user_api.php' );
require_css( 'status_config.php' );
auth_ensure_user_authenticated();
category_get_all_rows( helper_get_current_project() );
compress_enable();
html_robots_noindex();
html_page_top('Time');
There is more after this, but the failed html_page_top means it does not get executed.
I did some testing and found PHP can see most of the functions in html_api.php, but not all of them.
Please help!
Re: PHP Fatal error: Call to undefined function html_page_t
Posted: 14 Dec 2017, 11:11
by rkarmann
Hi there,
So that we can help you, can you define what you are trying to do ?
ShadowKatmandu wrote:
Code: Select all
require_once( '../../../core.php' ); // This is in a plugin, so this is where core.php is found for me
Does that mean that your goal is to switch the original core.php file, or require it in a plugin ?
Re: PHP Fatal error: Call to undefined function html_page_t
Posted: 14 Dec 2017, 15:34
by ShadowKatmandu
All I am trying to do is have the standard MantisBT page appear, minus content. This doesn't involve core.php, other than it is required for Mantis stuff to show up.
Meanwhile, I have altered my methodology a bit. This is a plugin I am developing. I have changed the way it is linked, so I don't need to require_once('core.php'). It is now linked as
https://www.domain.com/plugin.php?page=myplugin/plugin instead of
https://www.domain.com/plugins/myplugin/pages/plugin. However, I get the same error. I tried this same code on MantisBT1.3.x, and it worked fine.
Re: PHP Fatal error: Call to undefined function html_page_t
Posted: 14 Dec 2017, 16:07
by rkarmann
Ok, I see. How are you linking your plugin's page into Mantis ? Using events ?
Re: PHP Fatal error: Call to undefined function html_page_t
Posted: 14 Dec 2017, 16:41
by ShadowKatmandu
I have added a menu item which links to
https://www.domain.com/plugin.php?page=myplugin/plugin. This is not an event-based plugin.
Re: PHP Fatal error: Call to undefined function html_page_t
Posted: 14 Dec 2017, 21:11
by rkarmann
Ok, just so you know, building a plugin in mantis 2.x require some knowledge in event system, even if it's not a necessity. I recommend you the following:
In your plugin's class, after the register() function, add the hooks() function, that will hook your customized menu item when event is triggered:
Code: Select all
function hooks(){
return array(
'EVENT_MENU_MAIN' => 'menu',
);
}
Then define the menu() function that is hooked to the EVENT_MENU_MAIN event (means that your function
menu() will be call once all menu items are set).
Code: Select all
function menu(){
$links = array();
$links[] = array(
'title' => plugin_lang_get("My plugin page"),
'url' => plugin_page("main_page", true),
'icon' => 'fa-columns'
);
return $links;
}
By doing this you can easily link a page from your plugin, but the most interesting part comes after.
In your plugin's main page, to keep Mantis look and structure :
Code: Select all
<?php
html_robots_noindex();
layout_page_header('Enter title here');
layout_page_begin(__FILE__);
# your HTML output here will be displayed as any content in mantis (you will keep the top and left bar, even the footer)
layout_page_end();
Hope it will help in any way !
Re: PHP Fatal error: Call to undefined function html_page_t
Posted: 14 Dec 2017, 21:33
by ShadowKatmandu
Thank you!
I had already done register and hooks (the plugin wouldn't even try to work without them), but was unaware of the layout functions. They do exactly what I need!