View Full Version : How would I go about doing this?
Blam Forumz
11-08-2004, 05:32 PM
Hi, im trying to make an 'Off Topic' BB Code. I got it working (It uses fieldset)
But what I want to do is make it so users can select in their profile whether to display it or not using profile fields.
I tried this
<if condition="$post['field9']"><fieldset><legend>Off Topic</legend><table><tr><td>
{param}
</td></tr>
</table></fieldset></if>
Field 9 is a single line text box
Thanks
/blam
Link14716
11-08-2004, 05:48 PM
Forget about a disappearing off topic BBCode unless you want to try to find a way to do it in functions_bbcodeparse.php.
I do have a creative alternative for you: use quote. Maybe make Off Topic be [quote=OffTopic]. Now edit the template bbcode_quote.
At the begining, put this: <if condition="$username != 'OffTopic'">
Then, at the end, put this: <else /><if condition="$post['field9']"><fieldset><legend>Off Topic</legend><table><tr><td>
$message
</td></tr>
</table></fieldset></if></if>
Save it and you have an instant off topic tag. :p
Be creative. ;)
Blam Forumz
11-08-2004, 06:03 PM
Thanks alot! But I wuold like it to be [ot], is that possible without editng funcions_bbcodeparse.php?
Thanks again
Edit - the codes that you gave me didnt work, nothing displays eevn if the field is blank now
Link14716
11-08-2004, 06:09 PM
Thanks alot! But I wuold like it to be [ot], is that possible without editng funcions_bbcodeparse.php?
Thanks again
Edit - the codes that you gave me didnt work, nothing displays eevn if the field is blank now
That's what the condition you posted did, if it's blank, it shouldn't show up. If you want to reverse this, you'd have to add a ! before the $ in the condition to mean if it is blank, show the code.
I know you're going to have to edit functions_bbcodeparse to use [ot], but it probably wouldn't be that bad of an edit.
Blam Forumz
11-08-2004, 06:12 PM
Thanks for your help, but ive decided to leave it how I orignally had it (Showing the code no matter what my users wanted out of it)
Link14716
11-08-2004, 06:18 PM
Alright, this is not tested at all, so don't blame me if I cause a nuclear explosion to blow up half the world.
In functions_bbcodeparse.php, find this:
// [QUOTE]
$bbcodes['custom']['find']['[quote]'] = '#\[quote\](<br>|<br />|\r\n|\n|\r)??(.*)(<br>|<br />|\r\n|\n|\r)??\[/quote\]#esiU';
$bbcodes['custom']['replace']['[quote]'] = "handle_bbcode_quote('\\2')";
$bbcodes['custom']['recurse']['quote'][0] = array('handler' => 'handle_bbcode_quote');
Now add this above it:
// [OT]
$bbcodes['custom']['find']['[ot]'] = '#\[ot\](<br>|<br />|\r\n|\n|\r)??(.*)(<br>|<br />|\r\n|\n|\r)??\[/ot\]#esiU';
$bbcodes['custom']['replace']['[ot]'] = "handle_bbcode_offtopic('\\2')";
$bbcodes['custom']['recurse']['ot'][0] = array('handler' => 'handle_bbcode_offtopic');
Now, find this:
// ###################### Start bbcodehandler_quote #######################
Add this above it:
// ###################### Start bbcodehandler_offtopic #######################
function handle_bbcode_offtopic($message)
{
global $vboptions, $vbphrase, $stylevar, $show;
// remove empty codes
if (trim($message) == '')
{
return '';
}
// remove unnecessary escaped quotes
$message = str_replace('\\"', '"', $message);
global $stopsaveparsed, $parsed_postcache;
if ($stopsaveparsed OR $parsed_postcache['skip'] == true OR !$vboptions['cachemaxage'])
{
$show['iewidthfix'] = (is_browser('ie') AND !(is_browser('ie', 6)));
}
else
{
// this post may be cached, so we can't allow this "fix" to be included in that cache
$show['iewidthfix'] = false;
}
eval('$html = "' . fetch_template('bbcode_offtopic') . '";');
return $html;
}
Now add the code you have in your first post to a new template called bbcode_offtopic, replacing {param} with $message.
Blam Forumz
11-08-2004, 06:28 PM
>_< Didnt work, sorry for all the trouble Ive caused, appreciate the help though.
(Half the world hasnt been blown up :P)
Link14716
11-08-2004, 06:31 PM
What didn't work about it? And is the old [ot] still there? (It shouldn't be).
What would someone put in field9 anyways? You said it was a single line text field.
EDIT: If this ends up working, you might want to add this: // don't know where else bbcodes are defined
'bbcode_offtopic',under this: 'option', in global.php.
Link14716
11-08-2004, 08:50 PM
By the way, it works fine here.
http://14716.info/ot_np_hacks.png
If it doesn't work for you, it has to do with your conditional, and I need more info to help you there.
EDIT: Changed to a URL, since it stretched all posts on this thread.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.