Please upgrade here. These earlier versions are no longer being updated and have security issues.

I would like to show table layout for desktops and modern layout for mobiles. Is it possible?

@peregrine suggested this
"you could write a plugin

this should work...

public function Gdn_Dispatcher_AfterControllerCreate_Handler($Sender) {
// change mobile layout to modern if mobile is detected.
if (IsMobile()) {
SaveToConfig('Vanilla.Discussions.Layout','modern', array('Save' => FALSE));
}
}
there may be other ways as well."
Tried it but not working. Don't know where I'm getting it wrong. Any other suggestions?

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Please post what you have tried.


  • added this function inside profile extender's class.profileextender.plugin.php file
    and the plugin is already enabled

  • peregrineperegrine MVP
    edited August 2015

    Tried it but not working.

    is not the best description. you could improve on this as far as what you see on desktop, what you see on mobile. what version of vanilla you have, what plugins you have enabled, and what theme you are using for default and what theme you are using for mobile.

    I assume you have the following in your conf/config.php

    $Configuration['Vanilla']['Discussions']['Layout'] = 'table';

    meaning your default setting is Table Layout for discussions.

    Several things to keep in mind and general basic rules that I follow.

    • don't modify core vanilla, it will get overwritten on next upgrade
    • don't modify plugins included with vanilla, it will get written on next upgrade.
    • your idea of mobile may be different then vanilla's idea of mobile.
    • plugin must be mobile friendly in description
    • when making changes in a plugin, generally a good idea, disable it and then re-enable it.
    • make a new plugin when testing things. *****
    • disable other plugins if necessary while you are testing your new plugin. you may have another plugin that conflicts with it or overrides what you are doing.

      this may provide some insights, troubleshooting mysterious problems:

    http://vanillaforums.org/discussion/comment/199091/#Comment_199091

    you can download

    and load this on your computer browser to test.

    http://chrispederick.com/work/user-agent-switcher/

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • sorry @peregrine
    I tried doing a new plugin too but didn't work
    So tried modifying other plugins :/
    Feeling confused

Sign In or Register to comment.