2011-01-19, 04:20 PM
I want to setup an theme only for a subdomain. In order so choose a theme based in the domain i changed the global.php and added the following lines.
The theme is now only used when the visitor is on the subdomain (and for testing purpos has sufficient rights).
When using the mobile theme i encountered a realy annoying problem. Some links within the board don't work. Thats because mybb uses mybb->settings['bburl'] to build some of these link (search, breadcrumb, ...) Some of these links can be fixed by a plugin and a hook in the relevant php. Also i could change core-files in order to get the right link back. But i would like to keep the code-changes to a minimum. Because of that i set the bburl within the if to the mobile-subdomain and all links are working just fine. The only problem i discovered so far is the german messages.lang.php. If a user posts within the mobile version, the email-notification uses the mobile link. In order to avoid this problem i hardcoded the links in the german message-file and all is fine now.
Internal link are no problem. The get fixed with a plugin.
Right now, i wonder if i could encounter more problems in this direction and if there would be a more elegant way that gets the links right without setting the bburl. Did anyone else use this bburl methode for a subdomain and found other problems?
if($_SERVER["SERVER_NAME"] == "m.theandroidblog.de")
{
// test for the right Usergroup
if($mybb->usergroup['canmodcp'] == 1)
{
// load mobile style
$loadstyle = "tid='7'";
// shorten the breadcrumb
$mybb->settings['bbname_orig'] = "tab";
}
else{
// use the normal theme
$loadstyle = "tid='6'";
}
// set the bburl to the mobile subdomain
$mybb->settings['bburl']= "http://m.theandroidblog.de";
}
The theme is now only used when the visitor is on the subdomain (and for testing purpos has sufficient rights).
When using the mobile theme i encountered a realy annoying problem. Some links within the board don't work. Thats because mybb uses mybb->settings['bburl'] to build some of these link (search, breadcrumb, ...) Some of these links can be fixed by a plugin and a hook in the relevant php. Also i could change core-files in order to get the right link back. But i would like to keep the code-changes to a minimum. Because of that i set the bburl within the if to the mobile-subdomain and all links are working just fine. The only problem i discovered so far is the german messages.lang.php. If a user posts within the mobile version, the email-notification uses the mobile link. In order to avoid this problem i hardcoded the links in the german message-file and all is fine now.
Internal link are no problem. The get fixed with a plugin.
$plugins -> add_hook('parse_message','staymobile_fixlinks');
function staymobile_fixlinks($m){
if($_SERVER["SERVER_NAME"] == "m.theandroidblog.de")
{
$m = preg_replace('|http://theandroidblog.de|i', 'http://m.theandroidblog.de', $m);
$m = preg_replace('|object type="application/x-shockwave-flash" (.*?) value="http\://www\.youtube\.com/v/(.*?)"(.*?)object|smi', '<a href="http://www.youtube.com/watch?v=$2&feature=player_embedded">YouTube Video Link</a>', $m);
}
else
{
$m = preg_replace('|http://m.theandroidblog.de|i', 'http://theandroidblog.de', $m);
}
return $m;
}
Right now, i wonder if i could encounter more problems in this direction and if there would be a more elegant way that gets the links right without setting the bburl. Did anyone else use this bburl methode for a subdomain and found other problems?