View Full Version : Custom Conditional BB-Codes: Create your own
Marco van Herwaarden
01-26-2005, 10:00 PM
Custom Conditional BB-Codes: Create your own - Version 1.00
Description
This Hack will give you all building blocks to create your own BB-Codes that eveluate different based on a condition. You can create almost any condition you want.
As an example full instructions are given to install a "text" BB-Code that will only show "text" to logged in users.
This hack is a result of the following 2 threads:
- https://vborg.vbsupport.ru/showthread.php?s=&threadid=75162 (now withdrawn)
- https://vborg.vbsupport.ru/showthread.php?t=74940
WARNING:
With exception of the provided example, does this hack need some basic PH-coding skills.
Tested on
- vB 3.0.6
Install Information
Install time: from 2 minute till ...... hours ;)
File edits: 1 - 5 (depending on configuration)
Template edits: 0
IT IS EXTREME IMPORTANT THAT YOU READ ALL INSTRUCTIONS CAREFULLY.
Features
- Included example will give you a Text BB-Code
- You can write your own conditional BB-Codes
- Post caching is modified not to include posts that contain user dependent conditionals.
- Post preview on forumdisplay.php is modified not to show text that contain user dependent conditionals.
Support
Support will be given in this thread.
I will not charge for this hack. But if you like it and are looking for a way to spend your money, paypal donations are always welcome (marcoh64@msn.com) ;)
Please click Install if you are using this hack
hi marco,
can you tell me why this does not work?
function handle_bbcode_noguest($code)
{
global $bbuserinfo;
// remove empty codes
if (trim($code) == '')
{
return '';
}
// Prevent caching if a BB-code is used that is userdependent
// Uncomment the following 2 lines if the parsing of the bb-code is user dependent.
// So:
// - If user permissions are checked
// - If usergroup is checked
// - if userid is checked
// - .....
// Leave commented if:
// - No checking is done
// - Checking is done based on forumid
// - ....
global $bbcodeparse_nopostcache;
$bbcodeparse_nopostcache = 1;
if ($bbuserinfo['userid'] == 0 OR $bbuserinfo['usergroupid'] == 2) // Guest
{
$code = "no guest!";
}
return $code;
}
usergroup 2 are those with 0 posts. i dont know why they still can see what lies beneath the tag. it still works for guests with this code but not for registered users with 0 posts. (usergroup id 2)
haha, i solved the "problem" myself. i just added usergroupid instead of userid.
thanks a lot for this great hack. everything works fine now! :)
roundhost
01-27-2005, 05:01 PM
I am going to have a play with this, as i have recently been developing an admin notes system where admins can leave notes in posts stating if somebody has done somethign wrong, rather than just editing the post ;)
ericgtr
01-27-2005, 07:21 PM
I am going to have a play with this, as i have recently been developing an admin notes system where admins can leave notes in posts stating if somebody has done somethign wrong, rather than just editing the post ;)
Marco, I wonder if this mod isn't exactly what I am looking for. Have a look at this mod I created for an embedded media player https://vborg.vbsupport.ru/showthread.php?s=&threadid=72162 I have left in beta because I have been unable to add contitionals to the custom bbcode to keep certain groups from being able to see it. If I am not mistaken this looks like it will do exactly that?
this will exactly display something different to different groups.
for example the media to the paying customers and an error notice to the guests.
i am just not too sure about the built-in archive of vb3.
Marco van Herwaarden
01-27-2005, 08:52 PM
this will exactly display something different to different groups.
for example the media to the paying customers and an error notice to the guests.
i am just not too sure about the built-in archive of vb3.
Hmm archive...
Not check for that one yet. I know it will work ok for:
- Normal post/thread viewing
- In all view modes (linear/threaded)
- Using cached posts
- Preview on forum index
Will try to check put the archive tomorrow.
@roundhost/eric
Yes i think it will work fine for what you want to do.
ericgtr
01-28-2005, 03:40 PM
Okay, here is what I have and it's not working for me i.e. nothing happens and it does not send the permissions error allowing anyone to view. Let's say I want to send a no permissions error code to my custom [media] BBcode.
I change all instances of mycustombbcode to media according to the instructions in Install Conditional Custom BB-Codes.txt and applied the instructed changes to functions_bbcodeparse.php
Then I make the proper additions to the functions_forumdisplay.php and it still does not block the group. Here is the function_bbcodeparse.php that I am using.
// Start Hack Conditional BB-Codes (MarcoH64)
// ###################### Start bbcodehandler_media #######################
function handle_bbcode_media($code)
{
// Define Global Variables if needed:
// global $neededglobalvarnames;
// remove empty codes
if (trim($code) == '')
{
return '';
}
// Prevent caching if a BB-code is used that is userdependent
// Uncomment the following 2 lines if the parsing of the bb-code is user dependent.
// So:
// - If user permissions are checked
// - If usergroup is checked
// - if userid is checked
// - .....
// Leave commented if:
// - No checking is done
// - Checking is done based on forumid
// - ....
// global $bbcodeparse_nopostcache;
// $bbcodeparse_nopostcache = 1;
if ($bbuserinfo['usergroupid'] == 6)
{
// You can change the following to whatever suits you, text and/or html
$code = "<b>You must be registered to view the embedded media player</b>";
}
return $code;
}
// End Hack Conditional BB-Codes (MarcoH64)
Any ideas on what i am doing wrong?
Marco van Herwaarden
02-04-2005, 02:51 PM
Yes 2 things are wrong:
1. Since this condition is user dependant, you will need to uncomment the line:
// $bbcodeparse_nopostcache = 1;
2. You will need to change the line:
// global $neededglobalvarnames;
to:
global $bbuserinfo;
in top of the function i think. See also the provided [noguest] example.
ericgtr
02-06-2005, 01:11 PM
Yes 2 things are wrong:
1. Since this condition is user dependant, you will need to uncomment the line:
// $bbcodeparse_nopostcache = 1;
2. You will need to change the line:
// global $neededglobalvarnames;
to:
global $bbuserinfo;
in top of the function i think. See also the provided [noguest] example.
It's still not working, here is what I have now. I log in as guest and can still see the custom bbcode (I am using 'media' as my bbcode' it's been changed in all instances).
// Start Hack Conditional BB-Codes (MarcoH64)
// ###################### Start bbcodehandler_noguest #######################
function handle_bbcode_media($code)
{
global $bbuserinfo;
// remove empty codes
if (trim($code) == '')
{
return '';
}
// Prevent caching if a BB-code is used that is userdependent
// Uncomment the following 2 lines if the parsing of the bb-code is user dependent.
// So:
// - If user permissions are checked
// - If usergroup is checked
// - if userid is checked
// - .....
// Leave commented if:
// - No checking is done
// - Checking is done based on forumid
// - ....
global $bbcodeparse_nopostcache;
$bbcodeparse_nopostcache = 1;
if ($bbuserinfo['userid'] == 0) // Guest
{
// You can change the following to whatever suits you, text and/or html
$code = "Sorry this text is not viewable by guests.";
}
return $code;
}
// End Hack Conditional BB-Codes (MarcoH64)
Marco van Herwaarden
02-06-2005, 03:16 PM
Did you made the file edits as instructed in "Install with user based conditionals.txt" and optionally in "Install with use of post cache.txt"?
PS You could try the "noguest" example. It is almost the same as what you want, and tested.
ericgtr
02-06-2005, 03:45 PM
Yes, I have made all the changes that I think are necessary, even copied the noguest directly in and just changed 'noguest' to 'media'. It's a neat mod but overall it's rather confusing, what I am after is taking my custom bbcode whatever.com and making it so guests cannot see it. I find myself reading the documentation over and over but there are too many variables (uses) so I am not sure whether I need to add stuff, not add stuff to certain sections or not. I have tried many variations and none have worked.
Marco van Herwaarden
02-06-2005, 03:51 PM
Well nothing will go wrong if you do all optional modifications. I tried to make it less work for those that are not so happy with too many file edits, but i can understand this might also make things confusing.
Did you make a new post AFTER all the file edits?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.