can I hide a block or replace by link on mobile devices only

Permalink
Hi there,

I have a lot of c5 pages that I have to update and make responsive or at least make them work better on mobile devices.

There are some things that have probably nothing at all to do with c5 that I cannotget the hang of.

How do I manage to send a user to a subdomain like m.mypage.com if he visits from a smartphone or tablet? I thinks it is something in the css?

Is there a way to replace blocks with text links for mobile? Like there is a google map on my page. All the page is responsive only the map isn't and ruins the design. Can I hide the map and replace it with a text link to the map if someone views on a smartphone?

Would be very grateful for your help

rritz
 
enlil replied on at Permalink Reply
enlil
Here is an example of code you could use to display different content/classes based on mobile or tablet. alternatively The Magic Data add-on also has mobile detection built into symbols and could be used in a similar fashion.

<?php Loader::library('3rdparty/mobile_detect');
$page = Page::getCurrentPage();
$detect = new mobile_detect();
   if ($page->isEditMode()){
      ?><div class="globalheader-editmode"><?php
   } else { ?><div class="globalheader"><?php
      if($detect->isMobile() == true) {
         if ($detect->isTablet() == true) {
            echo t('Tablet');
            $stack = Stack::getByName('Global Header');
            if ($stack) {
               $stack->display();
            } else {}
         } else {
            echo t('Mobile');