Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » [solved] How to use Custom User Agents
[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" ) )
29-May-13 22:59:51
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. :
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
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.
Re: [solved] How to use Custom User Agents
- Index
- » MetaMod
- » MetaMod General Support
- » [solved] How to use Custom User Agents
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Posts this week:
- 2
- User Info:
- Total Users:
- 7628
- Newest User:
- horlogekorting34
- Members Online:
- 0
- Guests Online:
- 118
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked