1060

Error using trongate_administrators as the home page

Comments for “Error using trongate_administrators as the home page”
 

Posted by hugo on Monday 29th April 2024 at 16:26 GMT

Ahoy, :-)

I have an issue with the view file outputs, on the screen:
\xampp\htdocs\app_name\modules\trongate_administrators\views\tg_admin_template.php on line 27


It looks like it is an issue with this line:
<a href="<?= BASE_URL ?>trongate_administrators/create/<?= $data['my_admin_id'] ?>">


I guess 'my_admin_id' is not defined, but it works fine if I go directly to the URL:
/trongate_administrators/login

What is the difference between accessing the URL directly and using the configuration:
define('DEFAULT_MODULE', 'trongate_administrators');
define('DEFAULT_CONTROLLER', 'Trongate_administrators');
define('DEFAULT_METHOD', 'login');


Best regards,
Hugo
Level One Member

hugo

User Level: Level One Member

Date Joined: 28/04/2024

Posted by DaFa on Wednesday 1st May 2024 at 07:51 GMT

Hi Hugo, that is a strange issue you have discovered. I haven't spent much time looking into why it is doing that but you are correct 'my_admin_id' is not defined when the template 'tg_admin_template.php' is being required at line 155. I'm also not sure why you would want your app loading in the admin login form by default as this would normally be a hidden feature of your app. A better approach would be to use the simple members module instead.

However, a quick and easy fix is to leave the welcome module as your default:
define('DEFAULT_MODULE', 'welcome');
define('DEFAULT_CONTROLLER', 'Welcome');
define('DEFAULT_METHOD', 'index');
and change the index method to:
function index(): void {
	redirect('tg-admin');
	// $data['view_module'] = 'welcome'; // Indicates the module where the view file exists.
	// $data['view_file'] = 'welcome'; // Specifies the base name of the target PHP view file.
	// $this->template('public', $data); // Loads the 'welcome' view file within the public template.
}

This comment was edited by DaFa on Wednesday 1st May 2024 at 07:52 GMT

Founding Member

DaFa

User Level: Founding Member

Date Joined: 30/11/2018

Posted by hugo on Wednesday 1st May 2024 at 17:45 GMT

Thank you DaFa :-)

Yes, I know it is strange, but it follows the pattern of some server hosting control panels.

I know I could deep link it even further, but I wanted to be able to control where to put it. Even if it's in the root of the site and on an alternative port. Actually, I did not think about having an external redirect - like the web server itself. I am still learning, so alternative solutions do pop up in my mind, as the focus is on using Trongate for everything. It's my new favorite goto framework :-)

Best regards,
Hugo
Level One Member

hugo

User Level: Level One Member

Date Joined: 28/04/2024

×