BBcode: How to replace strings within BBcode tags

Get help developing custom BBCodes or request one.
Post Reply
hubaishan
Translator
Posts: 155
Joined: Sun Apr 10, 2011 2:47 pm
Name: Saeed Hubaishan
Contact:

BBcode: How to replace strings within BBcode tags

Post by hubaishan »

I want the way to replace strings within {TEXT} to build fast table bbcode like:

Code: Select all

[ftable]Name|Age|School
John|15|primary
Peter|18|high
Mark|12|primary
[/ftable]
this will be replaced by

Code: Select all

<table><tbody><tr><td>{TEXT}</td></tr></tbody></table>
I want BBcode is Equivalent to php:

Code: Select all

$TEXT = str_replace(array('|',"\n"),array('</td><td>',"</td></tr>\n<tr><td>"),$TEXT);
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: BBcode: How to replace strings within BBcode tags

Post by JoshyPHP »

You won't be able to properly implement that kind of custom markup with string replacements. If you want to use ASCII-style tables you should look into enabling the PipeTables plugin.

https://s9etextformatter.readthedocs.io ... /Synopsis/
https://s9etextformatter.readthedocs.io ... es/Syntax/
https://area51.phpbb.com/docs/dev/exten ... er-plugins
I wrote the library that handles markup in phpBB 3.2+.
hubaishan
Translator
Posts: 155
Joined: Sun Apr 10, 2011 2:47 pm
Name: Saeed Hubaishan
Contact:

Re: BBcode: How to replace strings within BBcode tags

Post by hubaishan »

GOOD!!
But is there a way to style table tag, set columns width.
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: BBcode: How to replace strings within BBcode tags

Post by JoshyPHP »

There are many ways and most of them are bad. That's why the PipeTables plugin exists.
I wrote the library that handles markup in phpBB 3.2+.
Post Reply

Return to “Custom BBCode Development and Requests”