Jump to content

What am I supposed to do with my own controllers


raxbg

Recommended Posts

Hi guys, so I write this module which adds extra functionality to the user account. I have hooked it to the myAccountBlock hook so I will have a link to my page for controlling to data of the new module. The question is, am I supposed to write new controllers and stuff to display this page, and if so am I supposed to copy all the files to their normal places during installation, or there is special place in my module folder for that? I mean should I copy a *.php file in the root folder, then a controller in controllers folder, and then the *.tpl to presta themes dir? This looks like hell if I want the module to be able to update itself. Thanks :)

Link to comment
Share on other sites

I mean should I copy a *.php file in the root folder, then a controller in controllers folder, and then the *.tpl to presta themes dir?

 

this is correct. since you are creating a brand new custom page, you cannot override the controller. however i suspect they would have expected you to use the module directory for this new page. so you would not have created a controller, that controller logic would have been within your module.

  • Like 1
Link to comment
Share on other sites

@bellini13 can you give me some pointers on how to do this. Since there is no hook for the new page to be displayed, how do I overcome the need of controller. I cannot explain good so I will give an example of the situation. I have hooked my module to myAccountBlock and there is a link leading to my-new-page.php(which is in the root folder). From there I am using a custom controller to the content I need. Therefore all the logic is in the controller file. So how do I keep the logic in the module main file and skip the need of custom controller? Thanks :)

Link to comment
Share on other sites

so it sounds like you hooked properly, except instead of placing a link to my-new-page.php in the root folder, keep the file in your module folder, and revise the my account link to point to it (/modules/mymodule/my-new-page.php).

 

Then place the controller logic directly into this php file, and use smarty to display using your template. check out the bankwire modules validation.php to get an idea on how to do this.

 

just make sure you have some code to ensure the customer is logged in (cookie check) before executing any code.

  • Like 1
Link to comment
Share on other sites

personally I like to create controllers if i am creating new pages. modules are good to hook into existing pages, so you can add some content to an existing page, but to create an entirely new page, i typically do what you initially did.

 

i don't believe there is a right answer here. the module option does keep you upgrade friendly, and would not be considered a core modification.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...