BBcode: How to replace strings within BBcode tags

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

BBcode: How to replace strings within BBcode tags

Post by hubaishan » Tue Nov 14, 2017 7:11 am

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: 754
Joined: Mon Jul 11, 2011 12:28 am

Re: BBcode: How to replace strings within BBcode tags

Post by JoshyPHP » Tue Nov 14, 2017 1:50 pm

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 thing that does the BBCodes in 3.2. Unless it broke yours, in which case it was somebody else with a similar name.

hubaishan
Translator
Posts: 86
Joined: Sun Apr 10, 2011 2:47 pm
Name: Saeed Hubaishan
Contact:

Re: BBcode: How to replace strings within BBcode tags

Post by hubaishan » Wed Nov 15, 2017 10:15 am

GOOD!!
But is there a way to style table tag, set columns width.

User avatar
JoshyPHP
Code Contributor
Posts: 754
Joined: Mon Jul 11, 2011 12:28 am

Re: BBcode: How to replace strings within BBcode tags

Post by JoshyPHP » Wed Nov 15, 2017 4:26 pm

There are many ways and most of them are bad. That's why the PipeTables plugin exists.
I wrote the thing that does the BBCodes in 3.2. Unless it broke yours, in which case it was somebody else with a similar name.

Post Reply

Return to “Custom BBCode Development and Requests”

Who is online

Users browsing this forum: No registered users and 4 guests

cron