1

I have some static pages on the site which will be rendered on mobile site as well. I will be serving these pages from the desktop application. To make it mobile design friendly, I need to hide the header and footer from the pages. These pages are cms pages, product pages etc..I can have the mobile pass some parameter in the URL to identify the referrer(cant use server referrer variable). example.com/comingfrom/mobile/privacypolicy.html.

From admin I tried adding

<remove name="header" />
<remove name="footer" />

under custom layout update xml and it worked fine but this removes header/footer forever. Where in the code I need to place this information? Which layout file to update? Thanks!

1

It seems like an awkward approach. You would probably be better off making the header and footer responsive.

In lieu of that, you could rewrite or replace those blocks with your own versions. In the block class's constructor, you can then check for a parameter in the URL and then set something like $this->setIsMobile(true) followed by a check in the template: $isMobile = $this->getIsMobile() - then simply alter your template to display what you like based on the state of $isMobile.

So if you check for mobile in the block's constructor, and mobile is true, you can then just not load the block or otherwise add some mobile content to the block in the template

  • There are multiple blocks and products which will be affected by it. I am looking for a more global approach. Something I can tackle when a page is rendering and check for $isMobile. – user6166 Mar 5 '15 at 22:39
  • I'm not sure what you mean. You want to hide those two blocks for mobile, right? So if you check for mobile in the block's constructor, and mobile is true, you can then just not load the block or otherwise add some mobile content to the block in the template. – pspahn Mar 5 '15 at 22:45
  • Thank you pspahn! I've added your comment as the answer. It worked perfectly. – user6166 Mar 5 '15 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.