Jump to content

Can I override another existing module's php file ..?


Recommended Posts

hello 

 

I want to override prestashop's existing module's main php file i.e "homefeatured/homefeatured.php"

because I want to pass smarty variable in the exist module's function such as when hook call like as follows i have edited homefeatured.php file to pass variable 

 

public function hookDisplayHome($params)

{
if (!$this->isCached('homefeatured.tpl', $this->getCacheId()))
{
if (Module::isInstalled('mymodule') && Module::isEnabled('mymodule'))
{
$this->smarty->assign(array(
'module_var_1' => Module::isEnabled('mymodule'),
'module_var_2' => Module::isEnabled('mymodule'),
'module_var_3' => Module::isEnabled('mymodule')
));
}
$this->_cacheProducts();
$this->smarty->assign(
array(
'products' => HomeFeatured::$cache_products,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
)
);
}
 
return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId());
}
 

 

Link to comment
Share on other sites

the override system does not apply to modules php files.

 

Thanks for the replay . So is there any another way to do this ...? because what I want to do actually is I want to replace "Add to cart" button (everywhere in store) with "get a quote " or any text for that in my module I successfully replace in product page of the store but in prestashop 1.6 there is two another module @ homepage which also have "Add to cart" button . but Im not replace that without editing main.php file of these module please help me...

[sorry for my english]

Link to comment
Share on other sites

"add to cart" most likely appears in the modules .tpl files and not their main php files.  you can override a modules .tpl file by making a copy of the file in your themes directory and editting it there.

 

for example, if the module is called "blockhome" and it has a template file called "blockhome.tpl", then make a copy of "blockhome.tpl" and place it in "/themes/<theme_name>/modules/blockhome/blockhome.tpl" and you can edit this file.

 

If "add to cart" does appear in the modules php file, then you have no choice but the edit the php file.

  • Like 1
Link to comment
Share on other sites

"add to cart" most likely appears in the modules .tpl files and not their main php files.  you can override a modules .tpl file by making a copy of the file in your themes directory and editting it there.

 

for example, if the module is called "blockhome" and it has a template file called "blockhome.tpl", then make a copy of "blockhome.tpl" and place it in "/themes/<theme_name>/modules/blockhome/blockhome.tpl" and you can edit this file.

 

If "add to cart" does appear in the modules php file, then you have no choice but the edit the php file.

 

I know that way overriding modules .tpl file but problem still exist like I want to pass smary variables such as module is enable / disable , text that come from admin side that replace "Add to Cart", etc, so many things I have to pass in their tpl file

Link to comment
Share on other sites

×
×
  • Create New...