jackads Posted April 4, 2012 Share Posted April 4, 2012 Hello guys, I'm new in PrestaShop, but I try a little in develop. I already created a module, but I would like that the module can be between the "cart" and the "new products". I can do this in the "position" tab in "modules" and change the position, etc, but I would like that the position already set when I installed the module... Anyone know how to help or say how to define the position of module in hook directly in the code? I'm with a little of dificult in found some information abou that, about define positions in the code. Thanks for your attention, God bless! Link to comment Share on other sites More sharing options...
bellini13 Posted April 4, 2012 Share Posted April 4, 2012 the Module class has a function called updatePosition. 1 Link to comment Share on other sites More sharing options...
jackads Posted April 9, 2012 Author Share Posted April 9, 2012 the Module class has a function called updatePosition. Hello Bellini, I have a friend here in Brazil with the same name! ;D I already know the function updatePosition, but this function don't update the module up or down only? (0 and 1 in parameters) I don't discovered how to make this in position directly. Because if I use updatePosition(6 , , 2) for an example this returned an error, but if I write a 0 or 1 in the second paremeter ir will update by up or down and not by position, or I an wrong? Another thing, how can I discover the id of my module withou need to test it by name? I make a thing like this: for ($id_module = 0 ; $id_module < 200 ; $id_module++){ $module = Module::getInstanceById($id_module); if($module->name == "mymodulename"){ code... } } I know it isn't the best option, but works for now, but I want to improve the code to make it in the right way. Sorry for mistakes and bad code, I'm only starting in php programming now, I'm learning yet. Link to comment Share on other sites More sharing options...
bellini13 Posted April 9, 2012 Share Posted April 9, 2012 you could try this, 1 will move the module up 1 position. then 2 will move it to the position 2. I'm not sure why the code is done this way, but give it a try and see if it does what you are wanting. updatePosition(6, 1, 2) if this does not work, then you just need to execute an insert statement directly, just like the themeinstallator module does. INSERT INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_hook`, `position`) VALUES ('.(int)$obj->id.', '.(int)Hook::get($hook[$count]).', '.(int)$position[$count].')'); Another thing, how can I discover the id of my module withou need to test it by name? first find the module by name $module = Module::getInstanceByName("module name") and then you can do $module ->id to get the id 1 Link to comment Share on other sites More sharing options...
jackads Posted April 9, 2012 Author Share Posted April 9, 2012 Really thanks Bellini! I will try this way. 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