-1

I have a doubt and not really sure about how is the best approach, I have a client with a website based on opencart with really bad practices on it, for example, all products are manually placed in the home page instead to be using the CMS capabilities of OC, right now the way it works is, if you are using a computer, full browser, the site displays the full version of the site, but if you are using an ipad or iphone/android device then loads the "small" version, both versions are placed manually in the same home.tpl document and they appear/disappear by some CSS. The question is, the client doesn't want to change the way the home page is designed, so instead to be loading that enormity of code is there a way to have a different tpl for the small version? for example a home.tpl version with the code for the full version and home-mobile.tpl for the small one? how this should work? How the system should determine the screen size and point to a TPL or other TPL?

I know it's a weird request but the client is "happy" with how the site looks like and don't want to change the manual code used on the home page.

Jay Gilford
  • 15,141
  • 5
  • 37
  • 56
ArturoCivit
  • 67
  • 1
  • 2
  • 8

1 Answers1

1

CSS is the correct way to handle the resizing and restructuring of the same content on different screens. If you want a vastly different homepage for mobile users, with different content, there are a couple of ways to do it:

  1. Detect the browser using JS and redirect to a mobile-only page. This would probably involve copying your current home controller (and template etc.) to a new file, or using a GET variable to switch templates further down the code.

  2. Detect the browser using PHP, and serve the correct template directly in the code. For this you could use a library like this one (untested, just an example) in your home controller, and change the template path as needed at the bottom of the script.

But first I would really try harder to emphasise to your client that he is doing it wrong.

rjdown
  • 9,162
  • 3
  • 32
  • 45
  • Thanks rjdown, I understand what you say at the end of your message but the client doesn't want to make that code different, at the end I'll try to deliver what he needs, that's why I think the different tpl for the home is the solution, the rest of the pages are going to be the same because, in a weird way, those inner pages are coded right, it is only the home page that is not properly coded. – ArturoCivit Mar 27 '15 at 22:51