PHP Fatal error: Call to undefined function html_page_top()

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
ShadowKatmandu
Posts: 20
Joined: 19 May 2014, 19:46

PHP Fatal error: Call to undefined function html_page_top()

Post 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!
rkarmann
Posts: 66
Joined: 24 Nov 2017, 10:00
Location: Lille, France

Re: PHP Fatal error: Call to undefined function html_page_t

Post 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 ?
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.
ShadowKatmandu
Posts: 20
Joined: 19 May 2014, 19:46

Re: PHP Fatal error: Call to undefined function html_page_t

Post 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.
rkarmann
Posts: 66
Joined: 24 Nov 2017, 10:00
Location: Lille, France

Re: PHP Fatal error: Call to undefined function html_page_t

Post by rkarmann »

Ok, I see. How are you linking your plugin's page into Mantis ? Using events ?
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.
ShadowKatmandu
Posts: 20
Joined: 19 May 2014, 19:46

Re: PHP Fatal error: Call to undefined function html_page_t

Post 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.
rkarmann
Posts: 66
Joined: 24 Nov 2017, 10:00
Location: Lille, France

Re: PHP Fatal error: Call to undefined function html_page_t

Post 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 ! :D
Last edited by rkarmann on 15 Dec 2017, 07:08, edited 1 time in total.
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.
ShadowKatmandu
Posts: 20
Joined: 19 May 2014, 19:46

Re: PHP Fatal error: Call to undefined function html_page_t

Post 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!
Post Reply