PDA

View Full Version : Removing a comma


smokey
11-24-2007, 03:07 PM
Trying to get the hang of the plugin system. I'm trying to remove the comma that separates the moderators on the moderator column. Eg it outputs mod1, mod2, mod3; basically i want to remove the comma and space for something I'm trying to accomplish. The thing is I do not want to do a file edit.

Here is the code from the function_forumlist.php

$showmods = array();
$listexploded = explode(',', $forum['parentlist']);
foreach ($listexploded AS $parentforumid)
{
if (!isset($imodcache["$parentforumid"]) OR $parentforumid == -1)
{
continue;
}
foreach($imodcache["$parentforumid"] AS $moderator)
{
if (isset($showmods["$moderator[userid]"]))
{
continue;
}

($hook = vBulletinHook::fetch_hook('forumbit_moderator')) ? eval($hook) : false;

$showmods["$moderator[userid]"] = true;
if (!isset($forum['moderators']))
{
eval('$forum[\'moderators\'] = "' . fetch_template('forumhome_moderator') . '";');
}
else
{
eval('$forum[\'moderators\'] .= ", ' . fetch_template('forumhome_moderator') . '";');
}
}
}

I want to insert a hook (forumbit_moderator) that will stop the execution of the code


$showmods["$moderator[userid]"] = true;
if (!isset($forum['moderators']))
{
eval('$forum[\'moderators\'] = "' . fetch_template('forumhome_moderator') . '";');
}
else
{
eval('$forum[\'moderators\'] .= ", ' . fetch_template('forumhome_moderator') . '";');
}

And replace with


$showmods["$moderator[userid]"] = true;
eval('$forum[\'moderators\'] = "' . fetch_template('forumhome_moderator') . '";');

Tried many things and just cannot get it to work right. Any suggestions?

Thanks!

Guest190829
11-24-2007, 03:13 PM
Just do whatever code you need in the hook, and use the continue statement, it will break out of the loop before doing the default vBulletin code.

smokey
11-24-2007, 03:47 PM
Just do whatever code you need in the hook, and use the continue statement, it will break out of the loop before doing the default vBulletin code.

I tired that first and got the following php syntax error:

Fatal error: Cannot break/continue 1 level in /home2/cmforums/public_html/includes/functions_forumlist.php(351) : eval()'d code on line 12

Guest190829
11-24-2007, 03:50 PM
Ahhh it is probably the eval affecting it...hm...

Is there a hook after it somewhere? You could explode the string, and format it as you want before the template is evaled..

smokey
11-24-2007, 04:11 PM
Ahhh it is probably the eval affecting it...hm...

Is there a hook after it somewhere? You could explode the string, and format it as you want before the template is evaled..

Yea there is one actually, thats a good idea, I'll try that.