Jump to content

How to define a hook?


d.crysty23

Recommended Posts

 I've managed to create a new hook and the changed code lines are presented below. However, I don't know how to assign this hook. I want the hook to be 900 px wide so that I can publish some modules within it. I hope you can help me, for I am out of ideas.

	// Call hook before assign of css_files and js_files in order to include correctly all css and javascript files
        $this->context->smarty->assign(array(
			'HOOK_HEADER' => $hook_header,
			'HOOK_TOP' => Hook::exec('displayTop'),
			'HOOK_HOME_TABS' => Hook::exec('displayHomeTabs'), //new hook
			'HOOK_LEFT_COLUMN' => ($this->display_column_left ? Hook::exec('displayLeftColumn') : ''),
			'HOOK_RIGHT_COLUMN' => ($this->display_column_right ? Hook::exec('displayRightColumn', array('cart' => $this->context->cart)) : ''),
			'HOOK_FOOTER' => Hook::exec('displayFooter')
		));

post-715508-0-89278600-1391459008_thumb.png

Link to comment
Share on other sites

 the code is a part of the FrontController.php file.. i've done some things by modifying grid_prestashop.css and header.tpl. I've put the changes both in the screenshot and in the code in this topic in order to be understood better. My hook can be found in the list when I click on "transplant module". The problem is that this pops up ("This module cannot be transplanted to this hook") when I want to make the module public in that respective hook. I wanted to move the featuredproducts.tpl file. I also know that a function is needed to allow the installing of this hook, but I don't know how to create that function and in what line to place it.

			<!-- Header -->
			<div id="header" class="grid_9 alpha omega">
				<a id="header_logo" href="{$base_dir}" title="{$shop_name|escape:'htmlall':'UTF-8'}">
					<img class="logo" src="{$logo_url}" alt="{$shop_name|escape:'htmlall':'UTF-8'}" {if $logo_image_width}width="{$logo_image_width}"{/if} {if $logo_image_height}height="{$logo_image_height}" {/if}/>
				</a>
				<div id="header_right" class="grid_9 omega">
					{$HOOK_TOP}
				</div>
			</div>
<div id="center_column2" class="grid_10">($HOOK_HOME_TABS)</div>
			<div id="columns" class="grid_9 alpha omega clearfix">
				<!-- Left -->
				<div id="left_column" class="column grid_2 alpha">
					{$HOOK_LEFT_COLUMN}
				</div>

				<!-- Center -->
				<div id="center_column" class=" grid_5">
				
	{/if}
.grid_10{float:left;}

post-715508-0-01836600-1391505738_thumb.png

post-715508-0-50905700-1391505741_thumb.png

Link to comment
Share on other sites

UPDATE: I've added the following code

public function hookdisplayHomeTabs($params)
{
$this->context->controller->addCSS(($this->_path).'homefeatured.css', 'all');
} 

in homefeatured.php file. I found it on the internet, and it seems that I've managed to move the hook of the module but with no effect. The object is still there although I got the following mesage"The module transplanted successfully to the hook."

 

 

post-715508-0-58068600-1391509829_thumb.png

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