1
techdb
PHP Hack to Redirect for IE6 Theme
  • 2009/9/27 1:06

  • techdb

  • Just popping in

  • Posts: 23

  • Since: 2005/3/7 1


I am getting tired of IE6 hacks to make current theme backward compatible and would like to isolate IE6 users to an old theme.

I am looking for a XOOPS core PHP hack that will automatically redirect users to an IE6 theme if that is the browser detected. Where is the theme loaded in XOOPS? Is there an easy way to do this?

I tried sticking this in common.php but nothing happened... any ideas?

// IE6 string from user_agent
$ie6 = "MSIE 6.0"; // detect browser
$browser = $_SERVER['HTTP_USER_AGENT']; // yank the version from the string
$browser = substr("$browser", 25, 8); // if IE6 set the $alert
if($browser == $ie6){ define("XOOPS_THEME_URL", XOOPS_URL . "/ie6themes"); }

2
ghia
Re: PHP Hack to Redirect for IE6 Theme
  • 2009/9/27 6:13

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


You can add xoops_theme_select=themeName to the URL to have the theme selected with a redirect.
Depending on the presence of other queries in the URI, you need to proceed it with ? or &.
eg.
/index.php?xoops_theme_select=themeName
/modules/newbb/viewtopic.php?post_id=317254&xoops_theme_select=themeName#forumpost317254
(Mind the fragment)

In PHP you can set the $_SESSION['xoopsUserTheme'] variable to the required theme name.
Must be done before loadTheme() is called in /class/theme.php (it is probably the best file for hacking this).
In principle the setting or redirect is only needed for the first access.
The theme must be set available /selectable in the preferences.

3
techdb
Re: PHP Hack to Redirect for IE6 Theme
  • 2009/9/28 1:21

  • techdb

  • Just popping in

  • Posts: 23

  • Since: 2005/3/7 1


Thanks for your quick response ghia.

I tried sticking the following code pretty much everywhere inside the theme.php file. Currently it resides at the very beginning just prior to the class xos_opal_ThemeFactory.

It works to redirect XOOPS on IE6 only when the browser is refreshed. When I load IE6 and start a new session the default theme shows up. If I hit the refresh button on IE6 then it is correctly redirected to the IE6 theme with this code in place. I tried changing a few other things around but nothing seemed to work.

I imagine it must be something with the new session going to the default theme... not sure however or if this is the problem or how to change.



// IE6 string from user_agent
$ie6 = "MSIE 6.0"; // detect browser
$browser = $_SERVER['HTTP_USER_AGENT']; // yank the version from the string
$browser = substr("$browser", 25, 8); // if IE6 set the $alert
if($browser == $ie6){ $_SESSION['xoopsUserTheme'] = 'ie6theme';}

4
ghia
Re: PHP Hack to Redirect for IE6 Theme
  • 2009/9/28 9:47

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Seems I looked in a wrong version.
Best place to add is probably common.php before processing of xoops_theme_select.

5
techdb
Re: PHP Hack to Redirect for IE6 Theme
  • 2009/9/28 23:37

  • techdb

  • Just popping in

  • Posts: 23

  • Since: 2005/3/7 1


Works perfect. Many thanks.

Login

Who's Online

173 user(s) are online (114 user(s) are browsing Support Forums)


Members: 0


Guests: 173


more...

Donat-O-Meter

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

Latest GitHub Commits