Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

is it possible to set "Home Page" on basis @media screen size ?

+4 votes
228 views
asked Aug 26, 2017 in Q2A Core by esqeudero

is it possible to set "Home Page" on basis @media screen size ? For example: 

  • if @media min-width: 980px then home page is default. (Recent questions and answers)
  • if @media max-width: 979px then home page is hot question.

Q2A version: 1.7..4

1 Answer

+2 votes
answered Aug 26, 2017 by pupi1985
selected Aug 31, 2017 by esqeudero
 
Best answer

A home page is something you define server side. Media queries run client side.

However, I can think of three ways of faking a similar behaviour.

Scenario 1: you are thinking of making many changes based on mobile devices. In this case it makes more sense to create a new mobile theme. You can perform server-side redirections on the mobile theme or do whatever you want. You can set it in admin/general.

Scenario 2: you are thinking of making a few amount of changes based on mobile devices. In this case it would make more sense to reuse your current theme and adapt it in a similar way as before. However, you won't know if the requesting device is actually mobile but you could at lest call the qa_is_mobile_probably() and decide the content to display on the fly. Note all these changes are server-side as well.

Scenario 3: you could add a piece of JavaScript on your theme that checks for the windows size (e.g.: https://stackoverflow.com/questions/1248081) and then perform a simple window.location.href = "http://yoursite.com/any-page". This solution would be client-side and really respects the viewport size rather than guessing on whether the device is mobile or not.

...