PDA

View Full Version : BB Code Enhancements - Cel PHP in Custom BBCode


cellarius
06-07-2011, 10:00 PM
This addon allows for PHP-Code to be used in Custom BBCodes


It offers a framework for the easy integration and sharing of custom BBCodes that are based on PHP processing of the data entered by the user. It could, for example, be used to develop BBCodes that use multiple options or to poll database information. It does allow for the Admin to use PHP in the Backend - it does, of course, not allow this to forum visitors.

You need to know PHP to use this Addon to develop your own PHP based bbcodes, however it would be possible to share them as an extension to this addon.


Installation:
- install the product file - done.


Using PHP in Custom BBCodes:
Create your Custom BBCode as always, and just put your PHP into the Replacement box (where the HTML used to go).Just remember two things:
Your code needs to start with <?php
You need to return the result of your code.If you're unsure what that means, read the php manual on eval() and look at the evaltest example in the second post (https://vborg.vbsupport.ru/showpost.php?p=2205046&postcount=2).

For coders: include instead of eval
If you'd rather store the PHP for your new BBCodes in the file system for ease of development, that's possible, too:
create a folder called "custombbcodes" in your forum root
in that folder, create a php file that copies your BBCode Tag Name (ie. if your tag name is "includetest", the file needs to be called "includetest.php"). That's where your PHP goes.
in the Replacement box in the Custom BBCode Dialog, just put the word "include", nothing else
Since there's no eval() here, no need to return the result. Instead, it needs to go into $parsed.There's also an includetest example in the second post (https://vborg.vbsupport.ru/showpost.php?p=2205046&postcount=2).No Support for your PHP-Code!

### See the example BBCodes in the second post (click (https://vborg.vbsupport.ru/showpost.php?p=2205046&postcount=2))! ###


### Don't forget to click install (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=264896)! ###
(No support if you don't)

cellarius
06-08-2011, 01:59 PM
PHP BBCode Examples:

To test them, go to AdminCP->Custom BB Codes->Add new BB Code and fill in the form:

--------------------------------------------------------------------
Title: evaltest
BBCode Tag Name: evaltest
Replacement:<?php
/*
Please note:

- available variables:
param => $value, option => $option
remember: param

- pass your result via return (as needed for PHP eval)
so end your code with return $my_result */

$my_result = "Test per eval (here no option was used): ";
$my_result .= "Parameter: <strong>" . $value . "</strong>";

return $my_result; ?>
Example: Hello World!
Use {option}: No--------------------------------------------------------------------
Title: includetest
BBCode Tag Name: includetest
Replacement:[code]include[code]
Example: Hello!
Use {option}: YesAdditionally, you need to create a directory called custombbcodes, and in it create a file called includetest.php with the following code:

<?php
/*
Please note:

- available variables:
param => $value, option => $option
remember: param
- all output needs to go to $parsed
no return statement needed (different from direct eval method)
so don't use echo "Hello World", but $parsed = "Hello World"
*/

$parsed = "Test per include (here option was used): ";
$parsed .= "Parameter = <strong>" . $value . "</strong>, ";
$parsed .= "Option = <strong>" . $option . "</strong>";
--------------------------------------------------------------------

AttalaEA
06-09-2011, 09:21 AM
Please I don't understand what this Mod is doing since I am a beginner can you please give us a simple clarification?

Thank You

cellarius
06-09-2011, 09:31 AM
If you're not familiar with PHP this addon probably is not for you. It allows you to use PHP code when processing BBCodes, so you are much more free when it comes to what you can do with BBCodes. You could do BBCodes with multiple options, for example, or poll your database for information. But you'd need to write the code for that yourself, this offers just the framework to run that code.

radiofranky
07-11-2011, 11:03 PM
this is what i'm looking for. T

cellarius
07-12-2011, 03:59 AM
Then mark as installed ;)

mishwar222
11-08-2011, 03:44 AM
Nice work! thank you

I need a little help please. I am trying to make bbcode with three options. I need the pop up form for the option to have three text areas for three inputs. It is ok with me if the contents of those areas got in one string after submitting them. I can divide them in the php file. is this possible? if not is there anyway to make a pop up form of my own?

lemonadesoda
12-01-2011, 10:02 PM
cellarius, this looks really useful! But could you kindly review your OP and possibly add more info, and clarify some potentially confusing language. Simplify your sentence construction so that someone who has english as a second language can understand 100%.

Same goes for your examples post. A more interesting third example would be great too! The magic is in the write up! Not just the code :-)

Kyojii
07-09-2012, 02:36 AM
If you needed to do a query with the value is it already sanitized?

cellarius
07-09-2012, 04:40 AM
Havn't checked that. Just give it a try.

Kyojii
07-09-2012, 06:35 AM
I checked it, and it appears it is.

Divvy
04-30-2013, 06:07 PM
Hello guys,

Can someone please help me?
I need to use this php code in my custom bbcode:

$(".my-content").sociallocker({
text: {
header: "Any message here!",
message: "Yes, this is test. Just try it, click on one of buttons."
}
});

How to do it correctly?

Thanks!

tbworld
04-30-2013, 07:13 PM
I think you should be posting this in the programming forum. This post does not apply to Cel's MOD.

I am trying to help, but I need to see the other part of this JavaScript / jquery code you are working with. You did not post PHP. Unfortunately it doesn't look like valid JavaScript or jquery either. So I am at a little bit of a loss to assist you.

Re-post as a new thread in the programming forum and post your source references, including function 'sociallocker'. Once we see the full picture it should be easy enough to help you.

grey_goose
04-02-2016, 11:07 PM
I'm a little late to the party, but finally ended up using this for a multi-variable bbcode.

Fantastic mod, it's got a lot more potential that has my imagination fired up :)