Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How can I make my theme also be used for mobile devices

lumiolumio New
edited April 2014 in Vanilla 2.0 - 2.8

Hello,

right now I'm developing a theme and I realised, that it won't be viewed for mobile devices. How can I make my theme mobile friendly?

Best Answers

  • hgtonighthgtonight ∞ · New Moderator
    Answer ✓

    You are looking to add an asset to the head module. Open up your theme hooks file and add the following:

    public function HeadModule_BeforeToString_Handler($Sender) {
      $Sender->AddTag('meta', array('name' => 'viewport', 'content' => 'initial-scale=1.0, width=device-width'));
    }
    

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Answers

  • Thanks for your quick response! And thank you :)

    I'm running Vanilla 2.1 now again.
    Your answer works perfectly... now I only need to be able to add <meta name="viewport" content="initial-scale=1.0, width=device-width"> to

    Do you know how to do that? :)

  • hgtonighthgtonight ∞ · New Moderator
    Answer ✓

    You are looking to add an asset to the head module. Open up your theme hooks file and add the following:

    public function HeadModule_BeforeToString_Handler($Sender) {
      $Sender->AddTag('meta', array('name' => 'viewport', 'content' => 'initial-scale=1.0, width=device-width'));
    }
    

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Very straight forward! Thanks!

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    You can also clone and modify your theme to work on mobile. Just make all the widths for content and panel 100% ...

  • @vrijvlinder said:
    You can also clone and modify your theme to work on mobile. Just make all the widths for content and panel 100% ...

    Which is not really a clean solution @vrijvlinder‌

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Really ? Please see my themes, the glass series has mobile themes to match. It is the same theme but altered to fit in mobiles. Have had no complaints yet .

    Not everything you put on a desktop theme works on a mobile. Sometimes you want different content for the mobile and ways to control the uploaded materials which may not conform to the size automatically .

    If you are going to use a desktop theme for mobile you will need to do much more than just adjust the window and scale the page to fit using that tag alone.

  • Yes of course you need to do more than just adjusting the window scale. Responsive is your friend ;)
    I just don't find it very clean, having a copy of a theme where you need to make global changes double and in two different places.

  • LincLinc Detroit Admin

    @lumio That's true, but it also compounds the difficulty of theming tremendously trying to make a solution that scales to both. We applaud folks who take on that challenge, but we also take the realistic view that many folks don't have that level of time to dedicate to their forum theme(s).

Sign In or Register to comment.