Jump to content

Mobile theme - Hide a module ?


botmez

Recommended Posts

Hello

 

I have a theme in my prestashop 1.5.6. installation: my website.mytheme

 

I have a folder in this folder named mobile -> my website/mytheme/mobile

 

I would like to hide some modules to customers when they access to my website with their mobile or tablet.

 

How can I do ?

 

thanks

Link to comment
Share on other sites

I have done this with some of my modules and believe there should be an option to show/hide each module with using mobile device.

 

This is my code for the testimonials block. (inside the main .tpl in the modules folder)

{if FrontController::ismobile()==true}

{else}

<!-- Block testimonial module -->
	<div id="block_testimonials" class="block">
		<h4><a href="{$this_path}testimonials.php">{l s='Testimonials' mod='blockTestimonial'}</a></h4>
			<div id="randomtestimonial">
			<p class="testimonialSpeech" >"<a href="{$this_path}testimonials.php#{$randomTestimonialid}">{$randomTestimonialtxt|strip_tags|truncate:180:'...'}</a>"</p>
			</div>
				   <div align="center" class="blocktestimonial">
				     <a class="button_large" href="{$this_path}addtestimonial.php">{l s='Add Your Testimonial' mod='blockTestimonial'}</a>
		           
				   </div>
	</div>
<!-- /Block testimonial module -->

{/if}

basically, I added this before the code

{if FrontController::ismobile()==true}

{else}


and at the end of all the code


{/if}

So it says, if the device is mobile, show nothing, else show the code

 

:)

 

I don't think it can be used on anything that uses the smart cache though.

Because if you browse on a desktop the cache is created, then browse the same page on a mobile and the cache is used (instead of using the "don't show" code)

So for instance, I had to use conditional css rules to hide my blocktopmenu

 

Hope this helps :)

Link to comment
Share on other sites

  • 3 weeks later...
  • 11 months later...

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