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.

[Documentation] Different view in mobile theme?

TorbjornTorbjorn New
edited May 2012 in Vanilla 2.0 - 2.8

Hi
I am using one theme for the desktop theme and another for the mobile theme(the default).
When visitors load the desktop theme i have the default homepage to load the url: '/categories/discussions' (in Appearance-> Homepage).
But...
This is not ideal in mobile version of the forum.
So...
How do i code the mobile theme to load '/diskussions' instead?

Answers

  • Tried a number of tweaks but no luck.
    I tried to redirect to /discussions via 'mobile theme hooks'. Tried both html (HTTP-EQUIV) and javascript but when the mobile theme loads but then the browser goes in a infinitive loop. There must be a simple solution to this...
    Please advice.

  • just an idea - there probably is an easier way.

    maybe you could look at
    $this->FireEvent("AfterLoadRoutes");

    and do some sort of plugin

    test if mobile and modify

    look at library/core/class.router.php

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

  • Torbjorn said:
    ...but when the mobile theme loads but then the browser goes in a infinitive loop. There must be a simple solution to this...

    Besides peregrine's advice, I still think you're on the right track. Your redirect is working, problem is that it's working at the wrong time (too early).

    Redirect... Load Vanilla, which loads the default /categories/discussions/ view => redirect b/c of mobile, etc. => infinite loop.

    If you do the tweaking using peregrine's advice, you're closer to your solution.

    There was an error rendering this rich post.

  • Well. My main knowledge strongest platform is WordPress and i am learning Vanilla "as i go". I would be soooo grateful for a code exaple that shows how i can implement the code @peregrine adviced. Can i add the code in my mobile theme file class.mobilethemehooks.php?
    I added the HTTP-EQUIV there but as @UnderDog states it fires to early...

    This is the code i added to class.mobilethemehooks.php that fires to early:

    public function Base_Render_Before($Sender) {
          if (IsMobile() && is_object($Sender->Head)) {
    
          $Sender->Head->AddTag('meta', array('HTTP-EQUIV' => 'REFRESH', 'content' => "0", 'url' => "http://forum.mallorcanytt.com/discussions"));
    
         }
    }
    
  • I cannot help much, but there's a difference between :


    public function Base_Render_Before($Sender) { AND AfterLoadRoutes

    Maybe it's public function Base_AfterLoadRoutes($Sender) { or something similar.
    (with or without Base)
    I wish I could help more.

    There was an error rendering this rich post.

  • @peregrine do you think i can use AfterLoadRoutes in class.mobilethemehooks.php? If this is solved i think it would be a great 'How-To' article in the Wiki. I can write the article but i need help with a working code snippet. Anybody else that can help out?

  • peregrineperegrine MVP
    edited May 2012

    After experimenting a little - I think the Before and AfterLoadRoutes is too late in the game.
    I'm no expert at all in .htaccess files, but maybe they will help you

    here are some links.

    http://stackoverflow.com/questions/3680463/mobile-redirect-using-htaccess

    http://stackoverflow.com/questions/9980498/htaccess-mobile-redirect-with-keeping-url-and-ajax-call-filtering

    http://wordpress.org/support/topic/how-to-redirect-links-for-mobile-using-htaccess

    http://www.webmasterworld.com/apache/4367451.htm

    other than that, I'm all out of ideas. sorry.

    Maybe an .htaccess expert can tailor it to your needs.

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

  • @Todd could you give à hint if what i want to do is event possible?
    @peregrine @underdog thank you so mutch for your time. I hope i can report back to you with the solution.

  • hope you get a solution - I'd like to see how to do this properly.

    It would be kind of cool - also if there was a dashboard setting in configuration that had an option for what you want to do (maybe in a future release).

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

  • peregrineperegrine MVP
    edited May 2012

    Any experts out there. could something be created here -

    conf/bootstrap.after.php

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

  • This one is interesting to figure out and document...

    You have to figure out exactly on which moment the /categories/discussions view (or another one) is loaded.

    I think you can only do that by looking at debug_backtrace at any given time.

    Browse through the lines of debug_backtrace and you'll see at which point that 'homepage' view is loaded.

    Let's see if that works...

    There was an error rendering this rich post.

  • I only get the debug info in my dashboard or if there is an error. cleared the cache. change the settings for manage view and debug. Thought I saw it on other pages once - but it too mystifies me as to how to initiate it on all pages.

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

  • @underdog and @peregrine Hang on for a few days. A solution is in progress.

  • Here is my contribution to this problem:
    http://vanillaforums.org/addon/mobiledefaultroute-plugin
    I hired x00 to write the community a plugin :-) Enjoy.
    @x00 thanks. Fast and professional work.

  • x00x00 MVP
    edited May 2012

    No worries :)

    grep is your friend.

  • Thanks guys!

    There was an error rendering this rich post.

  • the guy deserves a like for sponsoring a plugin don't you think.

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

Sign In or Register to comment.