Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

[solved] How to use Custom User Agents

[solved] How to use Custom User Agents

HI,

How can i use other User Agents as the once that are listed on the website?
For example if i use this script then only the "Googbot" gets detected:

Code:

if ( $core_genius->check( "browser_type = Test1-Bot, Test2-bot, Googlebot" ) )

Edited By: Jeff78
29-May-13 22:59:51

Jeff78
Beginner Modder
ranks
useravatar
Offline
11 Posts
Administrator has disabled public posting

Re: [solved] How to use Custom User Agents

Okay i got it finally working:

Code:

if (preg_match('/(Test1-Bot|Test2-bot)/i', $_SERVER['HTTP_USER_AGENT']))

{
  echo '<div class="cloud1">';
}
else
{
  echo '<div class="cloud2">';
}
?>
<p>Some HTML Output</p>
</div>
<*?php

Jeff78
Beginner Modder
ranks
useravatar
Offline
11 Posts
Administrator has disabled public posting

Re: [solved] How to use Custom User Agents

I still have a little problem i like to run the above script only on the Entry Page of the website (First Category Blog Page) but i don't know how to code this. sad :

Category Page 1 (Also the Entry Page of the website) - Debug Mode:

Code:

if (

$option == 'com_content'
and $view == 'category'
and $id == '8'
and $Itemid == '101'
and $jinput->get('layout') == 'blog' /*!*/
) return XXX;

Category Blog Page 2 - Debug Mode:

Code:

if (

$option == 'com_content'
and $view == 'category'
and $id == '8'
and $Itemid == '101'
and $jinput->get('layout') == 'blog' /*!*/
and $jinput->get('limitstart') == '4' /*!*/
and $jinput->get('start') == '4'
) return XXX;

And this here is the Script that i like to run on the Category Page 1 (Also the Entry Page of the website):

Code:

if (preg_match('/(Test1-Bot|Test2-bot)/i', $_SERVER['HTTP_USER_AGENT'])) 

{
  echo '<div class="cloud1">';
}
else
{
  echo '<div class="cloud2">';
}
?>
<p>Some HTML Output</p>
</div>
<*?php

Jeff78
Beginner Modder
ranks
useravatar
Offline
11 Posts
Administrator has disabled public posting

Re: [solved] How to use Custom User Agents

Ok, let's combine and simplify those a little. Here goes:

if ( !
( $option == 'com_content'
and $view == 'category'
and $id == '8'
and $Itemid == '101'
and $jinput->get('layout') == 'blog'
and $jinput->get('limitstart') == ''
and $jinput->get('start') == ''
) ) return; // short-circuit if we are NOT on the start page

// now we know we are on the start page, we can do the script:
if (preg_match('/(Test1-Bot|Test2-bot)/i', $_SERVER['HTTP_USER_AGENT']))
{
  echo '<div class="cloud1">';
}
else
{
  echo '<div class="cloud2">';
}
?>
<p>Some HTML Output</p>
</div>
<*?php


Hope that helps,
Stephen
p.s. remove the * from the last line - it's in there for some horrible technical reasons.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: [solved] How to use Custom User Agents

This is working now. big_smile
Thanks a lot for your help. wink

Jeff78
Beginner Modder
ranks
useravatar
Offline
11 Posts
Administrator has disabled public posting

Re: [solved] How to use Custom User Agents

oh, you must have spotted the missing ")" which I have added into the post above now... sorry about that.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1698
Total Polls:
6
Total Posts:
5944
Dormant:
User Info:
 
Total Users:
5595
Newest User:
gary099231
Members Online:
1
Guests Online:
545

Online: 
gary099231

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked