Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • markkusq3po Friend
    #183803

    Hello,

    does somebody know how and where to embed some code for browserswitching like this:

    [PHP]<?php
    function get_user_browser()
    {
    $u_agent = $_SERVER[‘HTTP_USER_AGENT’];
    $ub = ”;
    if(preg_match(‘/MSIE/i’,$u_agent))
    {
    $ub = “ie”;
    }
    elseif(preg_match(‘/Firefox/i’,$u_agent))
    {
    $ub = “firefox”;
    }
    elseif(preg_match(‘/Safari/i’,$u_agent))
    {
    $ub = “safari”;
    }
    elseif(preg_match(‘/Chrome/i’,$u_agent))
    {
    $ub = “chrome”;
    }
    elseif(preg_match(‘/Flock/i’,$u_agent))
    {
    $ub = “flock”;
    }
    elseif(preg_match(‘/Opera/i’,$u_agent))
    {
    $ub = “opera”;
    }

    return $ub;
    }
    ?>[/PHP]

    I tried to insert it in the index.php but just got an error page.
    Or does somebody knows something else to get Chrome using a separate css file?

    Thanks
    Markus

    Ninja Lead Moderator
    #479201

    You can put it here: templates/ja_mero/tpls/blocks/head.php

    markkusq3po Friend
    #479320

    Hello Ninja,

    great, that works so far.
    Do you have a little additional hint for me?

    I added this code too now after that first example code:

    $browser = get_user_browser();
    if($browser == “chrome”){
    <link href=”<?php echo T3V3_TEMPLATE_URL ?>/css/custom_chrome.css” rel=”stylesheet” />
    }

    but though this code is still inside the head the following output is rendered on the front page:

    $browser = get_user_browser(); if($browser == “chrome”){ }

    do you have a solution how i can hide that?

    Thanks Markus

    Ninja Lead Moderator
    #479327

    <blockquote>Open templates/ja_mero/tpls/blocks/head.php file</blockquote>
    You add this code below


    <?php
    $u_agent = $_SERVER['HTTP_USER_AGENT'];
    if(preg_match('/Chrome/i',$u_agent)):
    ?>
    <link href="<?php echo JURI::base(true) ?>/templates/ja_mero/css/custom_chrome.css" rel="stylesheet" />
    <?php
    endif;
    ?>
    With this is new path file: templates/ja_mero/css/custom_chrome.css

    Front


    <?php
    // Add T3v3 Basic head
    $this->addHead();
    ?>

    markkusq3po Friend
    #479388

    Hey, that works. This is more than great.
    Thousand thanks, you’re in the supporter heaven for me 😉
    Markus

Viewing 5 posts - 1 through 5 (of 5 total)

This topic contains 5 replies, has 2 voices, and was last updated by  markkusq3po 11 years, 9 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum