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
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
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.
Thanks I'll try it
Bookmarks