MyBB Community Forums

Full Version: Social Network - weird behavior of *some* themes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all!

Please don't judge me too hard - I'm a newbie in this forum and in MyBB in-general. =)

I was testing the GRA4 Social Network for MyBB (that one: http://mods.mybb.com/view/gra4-social-network ) on different themes, and encountered a weird thingie...

Well, let me back up a bit and explain the environment:
The scripts on the plugin run not as ...mybb/somescript.php , but as ...mybb/somedir/somescript.php

So, the weired thingie: I've noticed in that in ...mybb/somedir/somescript.php several themes show broken pictures in top menu, breadcrumbs, etc.
I'd like to highlight: only some themes, such as DarkFusion. The other ones, including the Default, work just fine.

After investigation I found out that the $theme['imgdir'] is broken, for example in DarkFusion the value is "images" instead of "images/darkfusion".
I did the print_r($theme) and guess what: there is serialized field there ("properties") containing exactly correct $imagedir = "images/darkfusion"

The question: Is there an API way to say to a theme: "Ok, dear theme, we run from this location, please adjust". Of shall I just implement a hook (if "yes" - where?) and brutally unserialize correct value over the wrong one ?

Thanks a lot
AT

MikeInToshx

Im not an expert either, but I know this:
When the URL is wrong, u'll have to adjust it manually, theres nothing out there that does it for you. So u'll have to change mybb/somedir/somescript.php to mybb/somescript.php
Well, the redesigning whole system to run this way probably is too much of the hassle... It's darn big system - social network. Especially considering the majority of the themes (again, including the Default one) work perfectly fine.
I've tested on about 15 different Themes - and found only 3 broken. Unfortunately it's some of the beautiful ones who do misbehave =)
I also see the mod works fine on other websites (other themes)
http://mybb.ucq.me/gra4/
http://www.rejuvenateforum.com/forum/gra4/
http://mybb.ciki.me/gra4/
http://gra4.ucq.me/mybb/gra4/



So it's gotta be a way to tell any theme how to operate on such configuration.

Any suggestion, guys? Pretty please ?
Well, I kinda found the solution...

The problem was: global.php works correctly only if executed in the "main" MyBB directory.
If not, and the theme uses custom image directory(like images/mythemedir), it will be reverted to default by this code:

	if(!@is_dir($theme['imgdir']))
	{
		$theme['imgdir'] = "images";
	}
So, if your plugin runs from subdir, include global.php like this:
chdir('..'); //global.php will drop $theme['imgdir'] to "images" if _relative_ dir $theme['imgdir'] does not exist, so we cheat...
include_once(dirname(__FILE__).'/../global.php');
chdir(dirname(__FILE__)); //return to normal 
and everything will work just fine an any theme.