Run PHP

Get help developing custom BBCodes or request one.
Post Reply
MathBlade
Registered User
Posts: 5
Joined: Fri Jan 18, 2019 6:15 am

Run PHP

Post by MathBlade »

Good morning,

So I have a multiple step question. Part of it is BBcode esque.

I also want custom PHP code to show up in between the two tags. This can change rather drastically based upon what the user has entered in another post.

So say for example, in post 0 there was a
[spoiler=settings]Settingsstring[/spoiler]
tag present.

When a user presses reply the tagnnamehere button on a reply, it would take Settingsstring and do some stuff with it and then create a string called "Output" which could be something like

Code: Select all

[b]AMAZING OUTPUT[/b]
<HTML replacement>BOLD TEXT SAYING AMAZING OUTPUT HERE<FINISH HTML REPLACEMENT FROM BBCODE>

It's a similar idea to how the "Bold" tag works.

What I've tried to do is add my own constant in constants.php and set it to match the BBcode ID that has my html
Added an entry into the case statement for following the same logic
Added a bbcode_tagnameheere function to message_parser.php
Added a case switch to bbcode_init for tagname here.
Cleaned the cache multiple times.

However the code seems to think this tag is still "custom" and doesn't try to use the PHP sections so therefore I'm not getting an error or anything to resolve.

So my question is twofold:
1) Is this the best way to do this? There is very strict whitelisting only of the data from the post 0 of the thread. If it doesn't match then an error string would be output.
2) If not, what is the suggested way to perform a similar function to add this text to the posting box to where the user can press preview, see it and then continue on?

Please excuse my poor artwork but this is what I want to achieve:

Image

Also apologies if this is in the wrong place, this seems like the right one. Should I be in the wrong place, I would appreciate you to redirect me and tell me where it went and what I could do better.

Thanks again for reading this and I hope for lots of fun replies.
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Run PHP

Post by JoshyPHP »

You need to create an extension, not modify files.

If you're handling scalar values, you can do this: https://area51.phpbb.com/docs/dev/3.2.x ... th-bbcodes
Otherwise, use this event: https://wiki.phpbb.com/Event_List#core. ... nder_after
I wrote the library that handles markup in phpBB 3.2+.
MathBlade
Registered User
Posts: 5
Joined: Fri Jan 18, 2019 6:15 am

Re: Run PHP

Post by MathBlade »

Thank you very much! I will look at those this weekend!
Post Reply

Return to “Custom BBCode Development and Requests”