Assistance in creating an Advanced Module
I'm creating an advanced module called "store" that will be an online store. What I have so far is a folder called "store" in the fuel/modules directory that contains the following directories:
assets
config
controllers
language
views
I've basically followed the instructions on this page in the manual:
http://getfuelcms.com/user_guide/modules/advanced so this means I have 3 files in the config folder called "store_constants", "store_routes" and "store", all of which have basic settings applied that I copied from other modules. To do a hello world type test for this module, I created a store.php controller and in the index function it simply echos out "Store" to the page.
It works, but makes me login to Fuel first to see it. How do I set it so that it doesn't authenticate to Fuel to bring up this module, like it does for the blog module?
Erik
Comments
<?php require_once(FUEL_PATH.'/libraries/Fuel_base_controller.php'); class Store extends Fuel_base_controller { function __construct() { parent::__construct(); // Initialize page_data array $this->page_data = array(); } function index() { $this->load->view('store', $this->page_data); } }
So, my question is what class should I use in this case to extend my controller class? I see that Fuel_base_controller extends CI_Controller. Should I use that? Are there any other options?
Erik
I have an additional question regarding routes. I want to have routes like this:
example.com/store/checkout/annual
example.com/store/checkout/3day
example.com/store/checkout/24hour
These are routes that will allow people to purchase annual, 3day and 24hour gift certificates for the bike share system. I have a store.php and a checkout.php controller. I have this route defined in a file under the store config folder called store_routes.php:
<?php $route['store/checkout/(annual|3day|24hour)'] = "store/checkout/index/$1";
This is currently not working, its returning a 404. Any idea what might be wrong?
Thanks,
Erik
$route['store/checkout/(annual|3day|24hour)'] = 'store/checkout';
It gives me a 404 if I do this:
$route['store/checkout/(annual|3day|24hour)'] = 'store/checkout/$1';
Why is the addition of the $1 causing this to break? The goal is to use the 3rd URI segment to apply a different price for each gift certificate type, so I would need that value to get passed to the store/checkout controller. I suppose the other option is to use $this->uri->segment(3) to pull it into the controller, but I still want to find out why it breaks when I add the $1 to the end.
Thanks
Cheers,
Erik
I have an issue when I go to example.com/store/checkout/success in that it is loading the checkout view instead of the success view. The checkout view is loaded by the _remap() function in the checkout controller. If I change _remap back to index, it fixes this problem, but then I won't be able to take advantage of having the 3rd URI segment pass in as a parameter to the checkout controller.
What exactly is the reason for the _remap function? Sounds like I just need to understand the behavior of this function better so that my module can function properly.
Erik
http://codeigniter.com/forums/viewthread/135187/
You are really close. I'll email you directly about meeting up.