Jump to content

Alternatives to modeules that don't hook


NicePack

Recommended Posts

Hi I've been seeing that lot of my problems setting up my page (using PS 1.6.0.7 and default-bootstrap template) is that there are some modules that don't hook in some determinated places. For example:

  • I wanted to hook Social buttons block to "displayHeader", next to logo but it says that this block can't be placed there.
  • Or I wanted to place Rapid search block to to "displayHomeTab" next to New Products and Featured Products buttons but it says it is not possible.

I know I could add this blocks in some other places and modify their margins with CSS but I'm afraid I'll break the responsive patterns of the template.

 

Are there alternatives to place this blocks... ummm... hard coding? Openning some .TLP and then ok, here call this block?

 

Thanks for any suggestions ^^

Link to comment
Share on other sites

Hi, to add additonal hooks to a module, you would need to update module/module_name/module_name.php

 

learn more here:  (it's not terribly difficult)

http://doc.prestashop.com/display/PS16/Managing+Hooks

 

tip: once you put a new hook in module, you will need to uninstall/install to register new hook

 

note: always back up any file that you are working with. :)

Link to comment
Share on other sites

Hi, to add additonal hooks to a module, you would need to update module/module_name/module_name.php

 

learn more here:  (it's not terribly difficult)

http://doc.prestashop.com/display/PS16/Managing+Hooks

 

tip: once you put a new hook in module, you will need to uninstall/install to register new hook

 

note: always back up any file that you are working with. :)

Hey thanks! I'm making dome progress, here's what I tried:

 

Opened blocksearch.php and added changed this content related to "displayHomeTab"

public function install()
	{
		if (!parent::install() || !$this->registerHook('top') || !$this->registerHook('header') || !$this->registerHook('displayHomeTabContent') || !$this->registerHook('displayMobileTopSiteMap'))
			return false;
		return true;
	}
	
	public function hookdisplayHomeTabContent($params)
	{
		return $this->hookTop($params);
	}

An then I added the hook in Prestashops dashboard Modules/Position/Add a new hook.

 

And it worked! Think I shoud change some CSS cause now is sticked with featured products but it seems correct enough ^^

 

The problem now is that I want to remove de one Search Block in Header and I tried to remove it's hook in header and here's the issue (in image attached). The block didn't disapear, it keeps showing in header and it losts it's style in both hooks (header and displayHomeTapContent)

 

search_block.png

Link to comment
Share on other sites

welcome to development.

 

when working on anything that exists, make sure to back up.

Thanks to the welcome. Of course I have backup my blocksearch.php and I can go back to previous search block state with no problem but it still don't know how to take out the Search Block from header or top hooks without loosing its style in "displayHomeTapContent" :/

 

It seems I should find the hookRightColumn or hookTop functions and copy it code in my modified blocksearch.php?

Link to comment
Share on other sites

It's a little bit hard :( Thx to El Patron advices, finally I found the way to put a search bar module in "displayHomeTabContent" and seems that with some CSS it will fit nice. But withe modules in header is other story.

 

I wanted to put a social block on the left of the header logo but can't find the way, it always go to corner upper left if I hook it on displayHeader or down to horizontal menu if I hook it on displayTop. No way to put it between nav bar and horizontal menu.

 

My code is this one:

 

blocksocial.php

public function install()
	{
		return (parent::install() AND Configuration::updateValue('BLOCKSOCIAL_FACEBOOK', '') && 
			Configuration::updateValue('BLOCKSOCIAL_TWITTER', '') && 
			Configuration::updateValue('BLOCKSOCIAL_RSS', '') && 
			Configuration::updateValue('BLOCKSOCIAL_YOUTUBE', '') && 
			Configuration::updateValue('BLOCKSOCIAL_GOOGLE_PLUS', '') && 
			Configuration::updateValue('BLOCKSOCIAL_PINTEREST', '') && 
			Configuration::updateValue('BLOCKSOCIAL_VIMEO', '') &&
			$this->registerHook('displayHeader') && 
			$this->registerHook('displayTop') &&
			$this->registerHook('displayFooter'));
	}
	
	public function getContent()
	{
		// If we try to update the settings
		$output = '';
		if (Tools::isSubmit('submitModule'))
		{	
			Configuration::updateValue('BLOCKSOCIAL_FACEBOOK', Tools::getValue('blocksocial_facebook', ''));
			Configuration::updateValue('BLOCKSOCIAL_TWITTER', Tools::getValue('blocksocial_twitter', ''));
			Configuration::updateValue('BLOCKSOCIAL_RSS', Tools::getValue('blocksocial_rss', ''));
			Configuration::updateValue('BLOCKSOCIAL_YOUTUBE', Tools::getValue('blocksocial_youtube', ''));
			Configuration::updateValue('BLOCKSOCIAL_GOOGLE_PLUS', Tools::getValue('blocksocial_google_plus', ''));
			Configuration::updateValue('BLOCKSOCIAL_PINTEREST', Tools::getValue('blocksocial_pinterest', ''));
			Configuration::updateValue('BLOCKSOCIAL_VIMEO', Tools::getValue('blocksocial_vimeo', ''));
			$this->_clearCache('blocksocial.tpl');
			Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&tab_module='.$this->tab.'&conf=4&module_name='.$this->name);
		}
		
		return $output.$this->renderForm();
	}

public function hookDisplayHeader()
	{
		$this->context->controller->addCSS(($this->_path).'blocksocial.css', 'all');
		if (!$this->isCached('blocksocial_header.tpl', $this->getCacheId()))
			$this->smarty->assign(array(
				'facebook_url' => Configuration::get('BLOCKSOCIAL_FACEBOOK'),
				'twitter_url' => Configuration::get('BLOCKSOCIAL_TWITTER'),
				'rss_url' => Configuration::get('BLOCKSOCIAL_RSS'),
				'youtube_url' => Configuration::get('BLOCKSOCIAL_YOUTUBE'),
				'google_plus_url' => Configuration::get('BLOCKSOCIAL_GOOGLE_PLUS'),
				'pinterest_url' => Configuration::get('BLOCKSOCIAL_PINTEREST'),
				'vimeo_url' => Configuration::get('BLOCKSOCIAL_VIMEO'),
			));

		return $this->display(__FILE__, 'blocksocial_header.tpl', $this->getCacheId());
	}

blocksocial_header.tpl

<div id="social_block_header">
	<ul>
		{if $facebook_url != ''}<li class="facebook"><a class="_blank" href="{$facebook_url|escape:html:'UTF-8'}">{l s='Facebook' mod='blocksocial'}</a></li>{/if}
		{if $twitter_url != ''}<li class="twitter"><a class="_blank" href="{$twitter_url|escape:html:'UTF-8'}">{l s='Twitter' mod='blocksocial'}</a></li>{/if}
		{if $rss_url != ''}<li class="rss"><a class="_blank" href="{$rss_url|escape:html:'UTF-8'}">{l s='RSS' mod='blocksocial'}</a></li>{/if}
		{if $youtube_url != ''}<li class="youtube"><a class="_blank" href="{$youtube_url|escape:html:'UTF-8'}">{l s='YouTube' mod='blocksocial'}</a></li>{/if}
		{if $google_plus_url != ''}<li class="google_plus"><a class="_blank" href="{$google_plus_url|escape:html:'UTF-8'}">{l s='Google+' mod='blocksocial'}</a></li>{/if}
		{if $pinterest_url != ''}<li class="pinterest"><a class="_blank" href="{$pinterest_url|escape:html:'UTF-8'}">{l s='Pinterest' mod='blocksocial'}</a></li>{/if}
		{if $vimeo_url != ''}<li class="vimeo"><a href="{$vimeo_url|escape:html:'UTF-8'}">{l s='Vimeo' mod='blocksocial'}</a></li>{/if}
	</ul>
</div>

And then I have this simple CSS tag in global.css but I tried lot of things to put it next to header logo with no success:

#social_block_header {
      width: 33%;
      padding: 6px 15px 0 15px;
}

Thanks for any advice.

 

P.D.: Sorry, page url is this one http://lamallorquina.onesixstudio.com/es/

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