1
tedsmith
Browser Reliant Blocks?
  • 2005/9/18 13:15

  • tedsmith

  • Home away from home

  • Posts: 1151

  • Since: 2004/6/2 1


Is there a way to tell XOOPS to only show a particular block if the browser being used to access the site is IE? I'm thinking of a small bit of html or php script? I'm having a problem with a block because the tag is an IE specific tag which FF (unsually) does not handle very well so I figure if I could just diasble it for FF users then that is one way round it.

I know it's not very 'webmasterish' but would be helpful seeing as 80% or so of web users still use IE.

Thanks

Ted

2
Mithrandir
Re: Browser Reliant Blocks?

Put the detection code in the block's show function and let it return false if the browser doesn't support it.
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

3
tedsmith
Re: Browser Reliant Blocks?
  • 2005/9/19 6:51

  • tedsmith

  • Home away from home

  • Posts: 1151

  • Since: 2004/6/2 1


Sounds good....except how do I do that?

Quote:

the detection code


I realise what that does, but what is it (code wise)?


Quote:

in the block's show function

Where would I find that and how do I change it?

Thanks

Ted

4
Dave_L
Re: Browser Reliant Blocks?
  • 2005/9/19 10:01

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


What kind of block is this?

If it belongs to a module, it has a "show-function" whose location you can determine by looking at the module's xoops_version.php file.

Example (from modules/system/xoops_version.php):

$modversion['blocks'][1]['file'] = "system_blocks.php";
$modversion['blocks'][1]['name'] = _MI_SYSTEM_BNAME2;
$modversion['blocks'][1]['description'] = "Shows user block";
$modversion['blocks'][1]['show_func'] = "b_system_user_show";
$modversion['blocks'][1]['template'] = 'system_block_user.html';


That block's show-function is named b_system_user_show and is in the file system_blocks.php (in the directory modules/system/blocks, since this example uses the system module).

If it's a custom block, it doesn't really have its own show function. You could place PHP code within the block to do the check, but I don't think there's any way of completely suppressing the block with that method; you could suppress the content of the block, but the title would still display.

For the detection code, you could examine the variable $_SERVER['HTTP_USER_AGENT'] using strpos() or preg_match().

5
tedsmith
Re: Browser Reliant Blocks?
  • 2005/9/19 15:32

  • tedsmith

  • Home away from home

  • Posts: 1151

  • Since: 2004/6/2 1


Hi Dave

In my case, it is a custom block, but the problem arose because of the marquee tag in the 'Marquee Module' originally. But the problem still occurs using a custom block and the marquee tag. This is why I wanted a workaround. Other solutions (java scripts etc) where just too intense for my simple list of scrolling text which had to be added to over time alphabetically.

So I could re-install the Marquee Module then try what you have suggested. However, although you've explained to me (very well) the 'blocks show function' you've not said how I'd apply the detection code? In the meatnime I'll try to look it up.

Thanks

Ted

6
Dave_L
Re: Browser Reliant Blocks?
  • 2005/9/19 16:14

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Can you assume that Javascript is enabled in the clients browser? If so, here's a way of doing it with Javascript: http://msdn.microsoft.com/workshop/author/dhtml/overview/browserdetection.asp

If you don't want to depend on Javascript, if you'll provide some examples of the value of $_SERVER['HTTP_USER_AGENT'] for IE and other browsers, I could provide a PHP code snippet for performing the check. You can dump out that information like this:

echo "HTTP_USER_AGENT='{$_SERVER['HTTP_USER_AGENT']}'";
?>

Login

Who's Online

357 user(s) are online (68 user(s) are browsing Support Forums)


Members: 0


Guests: 357


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits