Jump to content

Move Block Cart into Block TopMenu


Recommended Posts

Hi,

 

I would like to move the cart into the block topmenu, I tried this way :

 

- Created a hook named displayTopMenu (in the database ps_hook) manually

- Edited the blockcart.php , added in function install() :

|| $this->registerHook('displayTopMenu') == false

and created a function hookDisplayTopMenu : 

public function hookDisplayTopMenu($params)
	{
		return $this->hookTop();
	}

- Placed the hook in the TopMenu.tpl <li>{hook h='displayTopMenu'}</li>

- Added the module Cart in displayTopMenu in backoffice module position

 

It works... (i have my module where i want) but the cart now bugs. I suppose it's because of what i wrote in the function ( return $this->hookTop(); ) , i tried many other things, but it still doesn't work.

 

In picture, i have this :

post-364935-0-44374000-1399163561_thumb.jpg

and i want this :

post-364935-0-40737400-1399164061_thumb.jpg

 

Thank you in advance for you help !

Edited by Cale (see edit history)
  • Like 1
Link to comment
Share on other sites

you can do it without new hook.

move cart block right after the block top menu module on displayTop modules list (on page: modules > positions)

 

then modify blocktopmenu.tpl (in theme directory)

change code:
 

{if $MENU != ''}
	<!-- Menu -->
	<div id="block_top_menu" class="sf-contener clearfix col-lg-12">
		<div class="cat-title">{l s="Categories" mod="blocktopmenu"}</div>
		<ul class="sf-menu clearfix menu-content">
			{$MENU}
			{if $MENU_SEARCH}
				<li class="sf-search noBack" style="float:right">
					<form id="searchbox" action="{$link->getPageLink('search')|escape:'html':'UTF-8'}" method="get">
						<p>
							<input type="hidden" name="controller" value="search" />
							<input type="hidden" value="position" name="orderby"/>
							<input type="hidden" value="desc" name="orderway"/>
							<input type="text" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" />
						</p>
					</form>
				</li>
			{/if}
		</ul>
	</div>
	<!--/ Menu -->
{/if}

to:

	<!-- Menu -->
	<div id="block_top_menu" class="sf-contener clearfix col-lg-12">
		<div class="cat-title">{l s="Categories" mod="blocktopmenu"}</div>
		<ul class="sf-menu clearfix menu-content">
			{$MENU}
			{if $MENU_SEARCH}
				<li class="sf-search noBack" style="float:right">
					<form id="searchbox" action="{$link->getPageLink('search')|escape:'html':'UTF-8'}" method="get">
						<p>
							<input type="hidden" name="controller" value="search" />
							<input type="hidden" value="position" name="orderby"/>
							<input type="hidden" value="desc" name="orderway"/>
							<input type="text" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" />
						</p>
					</form>
				</li>
			{/if}
		</ul>

then in blockcart.tpl at the end of this file add:

</div>

you can stylize position of the block with position:absolute; right:0px; top:0px;

  • Like 2
Link to comment
Share on other sites

it's necessary to:

1) reconfigure top menu module (click save on module configuration page - contents will be generated again with changes you applies)

2) recompile entire theme and turn of cache (TEMPORARILY)

Link to comment
Share on other sites

Hello Vekia,

I tried the settings you described, but it does not work.
The code in the 'blocktopmenu.tpl' is well configured?
The blockcart still appears just below the 'blocktopmenu'.

 

Please, can you be more specific?

 

Thank you. :)

Link to comment
Share on other sites

  • 3 months later...

I am using this code for fixed top horizontal menu. I would like same thing like Cale - put the cart inside the menu. Does anybody know how? I tried code for Vekia, but it does not work.

themes/default-bootstrap/js/modules/blocktopmenu/js/hoverIntent.js

		var sticky = $('.sf-menu').offset().top;
		$(window).scroll(function(){
		
			if ($(window).width() > 1182){
				if( $(window).scrollTop() > sticky ) {
					$('.sf-menu').css({position: 'fixed', top: '0px','max-width':'1170px'});
				} else {
					$('.sf-menu').css({position: 'relative','max-width':'1170px'});
					
				}
			}
			if ($(window).width() > 974 && $(window).width() < 1183 ){
				if( $(window).scrollTop() > sticky ) {
					$('.sf-menu').css({position: 'fixed', top: '0px','max-width':'940px'});
				} else {
					$('.sf-menu').css({position: 'relative','max-width':'940px'});
					
				}
			}
			if ($(window).width() > 750 && $(window).width() < 975){
				if( $(window).scrollTop() > sticky ) {
					$('.sf-menu').css({position: 'fixed', top: '0px','max-width':'720px'});
				} else {
					$('.sf-menu').css({position: 'relative','max-width':'720px'});
					
				}
			}
			
	}); 
Link to comment
Share on other sites

  • 3 weeks later...

Hi Vekia,

 

When you suggest to edit blockcart.tpl and blocktopmenu.tpl

 

there are two locations which this file can be found

 

one is within /public_html/themes/default-bootstrap/modules/blockcart/blockcart.tpl  or another is /public_html/modules/blockcart/blockcart.tpl

 

You stated it is within the theme folder right?

 

Recompiled / Turn of Cache / Refresh Browser / Edited 2 tpl files / moved position in displaytop.

 

Now position sequence is quicksearch,cartblock,top horizontal menu in displaytop. looks all okay.

 

Seem to have tried everything but still can't get it to work..

 

It still shows the cart block underneath the top menu.

 

Using 1.609

 

Also i noticed you asked us to paste the code without the {if $MENU != ''} ? 

 

Thanks for your help.

Edited by ricky11 (see edit history)
Link to comment
Share on other sites

Hi.

I tried this, but dont work. blockcart will stay below topmenu as on attachment. I want it inside topmenu.

 

 

Changing div in blockcart.tpl (in theme) to below didnt change anything:

<div position:absolute; right:0px; top:0px; class="col-sm-4 clearfix{if $PS_CATALOG_MODE} header_user_catalog{/if}">

 

Tried on a test shop of skyborg.eu

version 1.6.0.9

 

Any ideas?

post-639094-0-40840700-1411421726_thumb.png

Link to comment
Share on other sites

I partly solved it. If i move both </ul> and </div> from topmenu.tpl to blockcart.tpl then cart works inside topmenu. See www.skyborg.eu

But on my testshop the blockcart hook delete itself all the time from displaytop, and cart is gone. If i add hook again it works for a little while. Any ideas?

Link to comment
Share on other sites

  • 2 months later...
  • 8 months later...
×
×
  • Create New...