Results 1 to 3 of 3

Thread: disable mobilecore for tablet

  1. #1
    User
    Join Date
    07-08-10.
    Location
    Madrid, Spain
    Posts
    145

    Default disable mobilecore for tablet

    Hello,

    I am adapting an existing site with mobilecore. I worked on mobile device, but for the moment, I want tablets to act as a normal computer.

    Is there a way to disable that part temporary ?

    Thanks
    Eric
    Contao 2.8 -> 3.0
    Evizer Web Agency

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: disable mobilecore for tablet

    Yes. The extension publishes a hook with which you can change the useragent.
    [code=php:3jug2vjh]<span class="syntaxdefault"></span><span class="syntaxcomment">//HOOK*to*set*another*user*agent*string
    </span><span class="syntaxdefault">if*</span><span class="syntaxkeyword">(isset(</span><span class="syntaxdefault">$GLOBALS</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'TL_HOOKS'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'setUAType'</span><span class="syntaxkeyword">])</span><span class="syntaxdefault">*</span><span class="syntaxkeyword">&&</span><span class="syntaxdefault">*is_array</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$GLOBALS</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'TL_HOOKS'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'setUAType'</span><span class="syntaxkeyword">]))
    {
    </span><span class="syntaxdefault">****foreach*</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$GLOBALS</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'TL_HOOKS'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'setUAType'</span><span class="syntaxkeyword">]</span><span class="syntaxdefault">*as*$callback</span><span class="syntaxkeyword">)
    </span><span class="syntaxdefault">****</span><span class="syntaxkeyword">{
    </span><span class="syntaxdefault">********$this</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">import</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$callback</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]);
    </span><span class="syntaxdefault">********$this</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">strAgent*</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">*$this</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">$callback</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]-></span><span class="syntaxdefault">$callback</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">](</span><span class="syntaxdefault">$this</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">strAgent</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">*$this</span><span class="syntaxkeyword">);
    </span><span class="syntaxdefault">****</span><span class="syntaxkeyword">}
    }</span><span class="syntaxdefault"></span>[/code:3jug2vjh]

    So you need an extension in /system/modules/mobilecore_yourname with these files inside:
    ./config/config.php
    [code=php:3jug2vjh]<span class="syntaxdefault"></span><span class="syntaxkeyword"><?</span><span class="syntaxdefault">php
    $GLOBALS</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'TL_HOOKS'</span><span class="syntaxkeyword">][</span><span class="syntaxstring">'setUAType'</span><span class="syntaxkeyword">][]</span><span class="syntaxdefault">*</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">*array</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'YourClass'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">*</span><span class="syntaxstring">'changeUserAgent'</span><span class="syntaxkeyword">);</span><span class="syntaxdefault"></span>[/code:3jug2vjh]

    ./YourClass.php
    [code=php:3jug2vjh]<span class="syntaxdefault"></span><span class="syntaxkeyword"><?</span><span class="syntaxdefault">php
    class*YourClass*extends*Frontend
    </span><span class="syntaxkeyword">{
    </span><span class="syntaxdefault">public*function*changeUser Agent</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$strAgent</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">*$objController</span><span class="syntaxkeyword">)
    {
    </span><span class="syntaxdefault">****if*</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">$strAgent*</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">*</span><span class="syntaxstring">'tablet'</span><span class="syntaxkeyword">)
    </span><span class="syntaxdefault">****</span><span class="syntaxkeyword">{
    </span><span class="syntaxdefault">********return*</span><span class="syntaxstring">'regular'</span><span class="syntaxkeyword">;
    </span><span class="syntaxdefault">****</span><span class="syntaxkeyword">}
    </span><span class="syntaxdefault">****return*$strAgent</span><span class="syntaxkeyword">;
    }
    }</span><span class="syntaxdefault"></span>[/code:3jug2vjh]

    This code is untested, might have errors and may not work as I gave it 5 min of thought. Use with care! You may also want to change the class and function names.

  3. #3
    User
    Join Date
    07-08-10.
    Location
    Madrid, Spain
    Posts
    145

    Default Re: disable mobilecore for tablet

    Thanks I'll try it
    Eric
    Contao 2.8 -> 3.0
    Evizer Web Agency

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •