MyBB Community Forums

Full Version: Change $lightbulb so that I can point to the on.gif and off.gif as a sprited image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So it seems $lightbulb defines the on/off.gif image
I'm trying to sprite all of my images and this little one is hard to find.

Essentially I want to turn the on.gif and off.gif into a sprited background image, but I will need to change somthing so that if:

{$theme['imgdir']}/{$lightbulb['folder']}.gif = off.gif, then instead of dispaying the off.gif image, I will point to a span with background-position:-1px -175px;

and if:

{$theme['imgdir']}/{$lightbulb['folder']}.gif = on.gif, then I will point to a span with background-position:-1px -155px;

One place that I think I need to update is here:
Template Sets » Default TemplatesEdit Template» forumbit_depth2_cat

Is there anyway I can put a bit of logic in this template to achive this, any adivice at where I should be looking (I know its also defined to ajax replace this in the javascript, but I'll turn that off)
In the javascript you'll have to make a change..I think it's jscripts/general.js. It's used there because it's clickable to mark as read.

yeah, I've temporarily deleted that line javascript:

$('mark_read_'+fid).src=$('mark_read_'+fid).src.replace("on.gif","off.gif");
This line seems to be only relvant on updating the on/off on the fly (mark as read),
as mentioned, I might turn that off.

However, if I go into forumbit_depth2_cat and remove {$theme['imgdir']}/{$lightbulb['folder']}.gif, this removes the image. So it seems that on first load, the javascript isnt responsible for displaying the images (I belive a query gets the status and updates $lightbulb['folder'] for that Forum Section... possibly)

Edit: Yup, I just did the following test:

<td class="{$bgcolor}" align="center" valign="top" width="1">
{$theme['imgdir']}/{$lightbulb['folder']}<img src="test.gif" class="ajax_mark_read" id="mark_read_{$forum['fid']}"></td>

And the image test.gif doesnt get changed to on.gif or off.gif, but the string "images/on" or "images/off" gets returned depending on the Forum Section. So $lightbulb['folder'] is based on a query.

even just doing this:
<td>{$lightbulb['folder']}</td>

Returns the strings "images/on" for some Forum Sections and "images/off" for others, so its seems to be query dependant for the given Forum Section. [I take it this isnt PHP your using inside the brackets {} ]

where can I update / change the array $lightbulb[], or can I add logic inside the backets:

{if $lightbulb['folder'] == "images/on" {print 'x';} else {print 'y';}} // I'm pretty sure this wont work, but a referance to what this language is and what will work would be really good Smile
<edit, these seem to be included PHP functions/arrays, there doesnt seem to be any direct way of wrapping them in conditional staments with the templates... please correct me if I'm wrong>

* Forum Section: the new row that is added when adding a New Fourm in the Admin CP

Esh, found it in :

defined in functions_forumlist.php:
$lightbulb = get_forum_lightbulb($forum, $lastpost_data, $showlockicon);

where get_forum_lightbulb returns
array("folder" => $folder,"altonoff" => $altonoff);
and $folder is the string "on" or "off" depending on query relating to last read.

So this is where I should start hacking around, hmmm...
ohhh yeah, daddy cool . That worked...

For those silly enougth to hack away, adding an extra parameter to the return stament of get_forum_lightbulb:

return array(
"backgroundclass" => $background,
"folder" => $folder,
"altonoff" => $altonoff
);

Will allow you to return a new parameter so that $lightbulb can return a class name(obviously you will need to define what $background is), that way the on.gif and off.gif can be controlled by the css (or however else you want to do it)