Jump to content

creating a custom hook above datasheet


haimbilia

Recommended Posts

hello everyone

im trying to hook a module above the data sheet

the module im trying to hook is called tagsicons:

http://addons.prestashop.com/en/19606-icon-tags-for-products.html

 

my theme is default-bootstrap 

my prestashop is version 1.6.1.4

 

i already registered a hook using the install of this module with this:

public function install() {
if !parent::install() || !$this->registerHook('displayRightColumnProduct') || !$this->registerHook('displayProductBeforeData'))
return false;
return true;
}

that worked well.

then i added this line above the <!-- Data sheet --> in product.tpl

			<section class="page-product-box">
				<div class="block_content">
					<ul id="usefull_link_block" class="clearfix no-print">
              {hook h='displayProductBeforeData'}
					<li class="print">
					</li>
				</ul>
				</div>
			</section>

then i added to 

tagsicons.php
 public function hookdisplayProductBeforeData($params)
    {
        $id_product = Tools::getValue('id_product');
        $id_lang = (int) $this->context->language->id;
        $product_tags = Tag::getProductTags($id_product);
        $tags = $product_tags[$id_lang];

        $icon_tags = array();

        if(is_array($tags)){
        foreach ($tags as $tag) {
            $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'tagsicons` WHERE id_lang = ' . (int) $id_lang . ' and name=\'' . pSQL($tag) . '\'';
            $tab_tag = Db::getInstance()->ExecuteS($sql);


            if (isset($tab_tag['0']) && $tab_tag['0']['name'] != '') {
                $icon_tags[] = $tab_tag;
            }
        }
        }

        $listado = false;

        $this->context->smarty->assign(array(
            'context_help' => Configuration::get('context_help_tagsicons'),
            'tag_link' => Configuration::get('tag_link_tagsicons'),
            'panelTitle' => Configuration::get('panel_title_tagsicons'),
            'listado' => $listado,
            'icontags' => $icon_tags,
            'mypath' => $this->_path
        ));
        $this->context->controller->addCSS($this->_path . 'views/css/tagsicons.css');
        return $this->display(__FILE__, 'views/templates/hook/tagsicons.tpl');
    }

and then i just hooked the module to displayProductBeforeData on the back office.

 

 the module is desplayed exactly where i want it but it is all messed up! is if there is no css loaded!

for example the icons are verticaly aligned instead of horizontaly.

 

post-979469-0-50986000-1460273696_thumb.png

 

 

now when i hook the module in displayRightColumnProduct it looks great also above the datasheet.

as you can see here:

post-979469-0-58458200-1460274967_thumb.jpg

 

 

can someone help me fix this?

thank you!

 

 

Link to comment
Share on other sites

the css works just fine if i manually include it in the header.

the problem is it is not being included unless i hook the module in displayRightColumnProduct

as you can see in the picture.

also if i hook it to displayProductTab it works fine.

so i believe i need to change something the product.tpl

Link to comment
Share on other sites

Not sure if I understand your problem correctly.

 

You can override setMedia() method of ProductController.php so that you can include the CSS style for your hook. You can directly include the CSS for your hook inside your theme file of your hook.

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...