Jump to content

Mobile version bootstrap


remove
 Share

Recommended Posts

I need some advice about the following.

Because the mobile version of my website is different from the desktop version it needs its own code. I'm using the visible-xs, hidden-xs in my basic-template. Does anybody have any ideas or got a better solution?

<?php include('./head.inc'); ?>

<div class="hidden-xs">
Code main website
</div>

<div class="visible-xs">
<?php include('./mobile.inc'); ?>
</div>

<?php include('./footer.inc'); ?>
Link to comment
Share on other sites

cannot really follow. Do you want to send both versions _everytime_ for every request, (also to mobiles with possible low bandwith) and want to hide maybe 50-70 percentage of the transmitted content?

Why do you not serve two different versions with different (base) URL or (sub)domain? And simply let the user decide which one he uses, like here in the IP.board. (with mobile you have a link on every page: [use full version] or [use mobile version])

Or use a UA-sniffer of your trust and send one version. https://processwire.com/talk/topic/6354-server-side-mobile-detection-with-caching/#entry62205

Link to comment
Share on other sites

You can include a file two ways.

With CSS you can simply have a div that includes various markup and use display: none for media quieries where you don't want to see it.

However, you can also use some ajax and load a page using jquery. So you would do something like:

var $window = $(window);
      function checkWidth() {
          var viewportWidth = $window.width();

          if(viewportWidth >= 1290) {

             load a page with ajax here

             } else {

             Load the same page with a different template here etc

          }
      }
    checkWidth();
    // Bind event listener
    $(window).resize(checkWidth);
});

So you can have a separate template for mobile layout and load that one or another depending on the viewport width. 

Warning: I am not a coder, so you will need to double check how to do this properly!

  • Like 1
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...