raxbg Posted April 9, 2012 Share Posted April 9, 2012 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 More sharing options...
bellini13 Posted April 9, 2012 Share Posted April 9, 2012 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. 1 Link to comment Share on other sites More sharing options...
raxbg Posted April 9, 2012 Author Share Posted April 9, 2012 @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 More sharing options...
bellini13 Posted April 9, 2012 Share Posted April 9, 2012 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. 1 Link to comment Share on other sites More sharing options...
raxbg Posted April 9, 2012 Author Share Posted April 9, 2012 Ok, this is what was confusing me, is it a good practice to make links to php files in my module folder. Thank you very much Link to comment Share on other sites More sharing options...
bellini13 Posted April 9, 2012 Share Posted April 9, 2012 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 More sharing options...
raxbg Posted April 9, 2012 Author Share Posted April 9, 2012 ok, so I will stick with the initial idea with the controllers Thank you again. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now