1084

Contact_us module isn't found...

Comments for “Contact_us module isn't found...”
 

Posted by Charles Luck on Monday 12th February 2024 at 03:09 GMT

I defined a module called contact_us, and it contains two directories, controllers and views.
The controller is called: Contact_us.php and inside is this...
<?php
class Contact_us extends Trongate {
    	function index() { 
		$data['view_module']     = 'contact_us'; 		
		$data['view_file']        = 'contact_us'; 
                $data['form_location']    = 'contact_us/submit';
		$this->template('soflo', $data); 	
	}
}


The view file is called: contact_us.php and inside are three sections of HTML + PHP. A contact form.

I have a link in the header top nav, and one in the about us page, both point to http://localhost/soflo/contact_us; which I would expect would trigger the index() method; but all I ever get is a 404 ERROR : PAGE NOT FOUND. I've tried everything to make this work, I can't figure out what the problem is. The code is exactly the same as that for the about_us page, which works perfectly.

Did I forget something?

Okay, in furtherance of transparency, I recreated my module using the "New Trongate Module" option in VSCode, reentered the code as before, and it totally works now. What I did not have prior is the api.json asset file which it created, and I wasn't aware that it was necessary, as I don't use it yet. But be that as it may, doing this solved my problem, but I can't say that I understand why.

This comment was edited by Charles Luck on Monday 12th February 2024 at 15:10 GMT

Level One Member

Charles Luck

User Level: Level One Member

Date Joined: 18/06/2023

Posted by djnordeen on Monday 12th February 2024 at 14:29 GMT

Just ofhand I would day it is the line with the form.
Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

Posted by Charles Luck on Monday 12th February 2024 at 15:18 GMT

Thank you dj,
I did remove the form_location and hardcoded the action value onto the form. The worst thing that should have happened is the submit would have thrown an error because that function hadn't been defined yet in the module. But, it really didn't get that far; it couldn't even find the module controller inwhich to execute the index function.
I do have Castelli's Trongate extension in my VSCode, and as much as I hate to rely on, even on prebuilt, modules (that's another discussion); in furtherance of transparency, I recreated my module using the "New Trongate Module" option in VSCode. Then reentered the code as before, and "it totally works" now. What I did not have prior is the api.json asset file which it created, and I wasn't aware that it was necessary. Or is it. Be that as it may, doing this solved the problem, but I can't say that I understand why.

This comment was edited by Charles Luck on Monday 12th February 2024 at 15:20 GMT

Level One Member

Charles Luck

User Level: Level One Member

Date Joined: 18/06/2023

Posted by djnordeen on Monday 12th February 2024 at 16:51 GMT

Charles,
Glad you sovled it.
The api should not have had anything to do with the form submission unless you were using JavaScript.
Dan
Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

×