Add BBCode

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Anti-Spam Guide
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
thegrandstand
Registered User
Posts: 18
Joined: Fri Sep 01, 2006 2:01 pm

Add BBCode

Post by thegrandstand » Sat Aug 04, 2007 12:44 pm

Hi,

I'm in the process of getting ready to swith to phpBB3. A competition I run on my current phpBB2 forum relies on tables (you now rows & columns etc...). I have been using the HTML Mod to create tables on my current forum.

Looking through a beta version of 3 I installed a while back I found the function where you can add a new BBCode. I was wondering if I could create a BBCode for tables using this? If so could someone please help me with the "BBCode usage" and "HTML replacement" to achieve this. I tried but it didnt work.

Thanks :)

dark/Rain
Registered User
Posts: 584
Joined: Mon Mar 19, 2007 4:50 pm

Re: Add BBCode

Post by dark/Rain » Sat Aug 04, 2007 1:10 pm

That shoud be quite easy... :)
Which tags do you actually want? Separate ones for table, tr, th, td etc?
Or something different?

thegrandstand
Registered User
Posts: 18
Joined: Fri Sep 01, 2006 2:01 pm

Re: Add BBCode

Post by thegrandstand » Sat Aug 04, 2007 1:19 pm

Hi,

I imagine the BBCode would be something like this...

Code: Select all

[table]
[tr]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[/tr]
[/table]
Here is what we currently do, just want to be able to achieve the same thing.

Thanks :)

User avatar
SpongeWeb
Registered User
Posts: 766
Joined: Thu Jan 27, 2005 2:57 pm
Location: End of the Universe
Contact:

Re: Add BBCode

Post by SpongeWeb » Sat Aug 04, 2007 1:26 pm

yeah

you could have:

Code: Select all

[table]{text}[/table]

<table>
<tr><td>{text}</td></tr>
</table>
you can make it more complicated if you need more than 1 cell, i.e

Code: Select all

[table]{text}{text2}[/table]

<table>
<tr>
<td>{text}</td>
<td>{text2}</td>
</tr>
</table>
this isnt exact, but you get the idea

thegrandstand
Registered User
Posts: 18
Joined: Fri Sep 01, 2006 2:01 pm

Re: Add BBCode

Post by thegrandstand » Sat Aug 04, 2007 1:37 pm

Ya I think I get it.

So I would have to specify the number of rows and columns?

dark/Rain
Registered User
Posts: 584
Joined: Mon Mar 19, 2007 4:50 pm

Re: Add BBCode

Post by dark/Rain » Sat Aug 04, 2007 1:47 pm

//Edit: a bit late, but anyway...:

Or, to have it more flexible (and similar to your existing tables):

Table (+width)

BBCode usage

Code: Select all

[table={NUMBER}]{TEXT}[/table]
HTML replacement

Code: Select all

<table width="{NUMBER}" border="1" cellspacing="0" cellpadding="0">{TEXT}</table>
Table row

BBCode usage

Code: Select all

[tr]{TEXT}[/tr]
HTML replacement

Code: Select all

<tr>{TEXT}</tr>
Table cell (+width)

BBCode usage

Code: Select all

[td={NUMBER}]{TEXT}[/td]
HTML replacement

Code: Select all

<td width="{NUMBER}">{TEXT}</td>
Table (+background colour)

BBCode usage

Code: Select all

[tdc={COLOR}]{TEXT}[/tdc]
HTML replacement

Code: Select all

<td bgcolor="{COLOR}">{TEXT}</td>
(It could be possible that you need to use {TEXT} instead of {COLOR} in case it doesn't work (since {COLOR} validates the value entered somehow)...)

Would be a nice possibility to switch to CSS-based styling, too :D

You can create quite a lot that way - just make sure you use the right tokens (the ones at the bottom of the Add/Edit BBCode page) and number them if necessary.

thegrandstand
Registered User
Posts: 18
Joined: Fri Sep 01, 2006 2:01 pm

Re: Add BBCode

Post by thegrandstand » Sat Aug 04, 2007 1:54 pm

Mate... you're a champion! I'll by you a beer (and drink it for you ;) )

I'll give that a whirl on my test forum and see how i goes.

Cheers :D

dark/Rain
Registered User
Posts: 584
Joined: Mon Mar 19, 2007 4:50 pm

Re: Add BBCode

Post by dark/Rain » Sat Aug 04, 2007 2:01 pm

Hm... You could be annoyed a bit (think I found a bug):

When you create such a table

Code: Select all

[table=800]
[tr]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[/tr]
[/table]
...you get quite a lot of newlines above it.

You'd have to use

Code: Select all

[table=800][tr][td]stuff here[/td][td]stuff here[/td][td]stuff here[/td][td]stuff here[/td][td]stuff here[/td][td]stuff here[/td][/tr][/table]
(i.e. put it all in one line) to avoid that as it seems -.-
Reporting it at the bug tracker...

//Edit:
...it doesn't actually insert the newlines above the table, but in between of the <td> tags :shock: :(
(understandable somehow but still invalid source code and unwanted...)

Seems to be a limitation of the Custom BBCode system... :( : http://www.phpbb.com/bugs/phpbb3/ticket ... t_id=13977

//Edit: Found a dirty and not-that-nice workaround... still testing...

thegrandstand
Registered User
Posts: 18
Joined: Fri Sep 01, 2006 2:01 pm

Re: Add BBCode

Post by thegrandstand » Sat Aug 04, 2007 2:45 pm

Hey thanks for your efforts, really appreciate it. :)

dark/Rain
Registered User
Posts: 584
Joined: Mon Mar 19, 2007 4:50 pm

Re: Add BBCode

Post by dark/Rain » Sat Aug 04, 2007 3:36 pm

You're welcome :D

OK, I don't think you want to use it, but here is the workaround:

The idea is the following: For (nearly) every newline inserted in the edit box, a <br /> is inserted into the page's source code - have a look at the source code when you post your (modified) example content.
(Some newlines are stripped out of the original post text, click "Preview" or save and edit the post to see that.)

To "neutralize" the "<br />"s, you can enclose them in HTML comments.

Now you only ( :lol: ) have to adapt the existing table BBCodes and create new ones (add the width stuff etc. if you want to use that)...:

tr

BBCode usage

Code: Select all

[tr]{TEXT}[/tr]
HTML replacement

Code: Select all

--><tr>{TEXT}</tr><!--
BBCode usage

Code: Select all

[trf]{TEXT}[/trf]
HTML replacement

Code: Select all

<tr>{TEXT}</tr><!--
BBCode usage

Code: Select all

[trl]{TEXT}[/trl]
HTML replacement

Code: Select all

--><tr>{TEXT}</tr>
td

BBCode usage

Code: Select all

[td]{TEXT}[/td]
HTML replacement

Code: Select all

--><td>{TEXT}</td><!--
BBCode usage

Code: Select all

[tdf]{TEXT}[/tdf]
HTML replacement

Code: Select all

<td>{TEXT}</td><!--
BBCode usage

Code: Select all

[tdl]{TEXT}[/tdl]
HTML replacement

Code: Select all

--><td>{TEXT}</td>
Usage:
tdf: first td in a table row
tdl: last td in a table row
td: all tds in between

the same for tr:

trf: first tr in a table
trl: last tr in a table
tr: all trs in between

Example:

Code: Select all

[table=800]
[trf]
[tdf]stuff here[/tdf]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[tdl]stuff here[/tdl]
[/trf]
[tr]
[tdf]stuff here[/tdf]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[tdl]stuff here[/tdl]
[/tr]
[tr]
[tdf]stuff here[/tdf]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[tdl]stuff here[/tdl]
[/tr]
[trl]
[tdf]stuff here[/tdf]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[td]stuff here[/td]
[tdl]stuff here[/tdl]
[/trl]
[/table]
You do only "have to use this" if you want to post your tables this way (or the way it gets reformatted after previewing and/or saving - at least at the moment)! If you write it all in one line, it's not necessary of course.

Hope I didn't miss anything...
It's probably not worth the effort, is it? (Maybe it is for your big tables and if only you use it?)

thegrandstand
Registered User
Posts: 18
Joined: Fri Sep 01, 2006 2:01 pm

Re: Add BBCode

Post by thegrandstand » Sun Aug 05, 2007 9:33 am

:D Works like a charm!

Thanks again dark/Rain!
Attachments
Sucessful Table BBCode in phpBB3
Sucessful Table BBCode in phpBB3
table_bbcode.JPG (22.96 KiB) Viewed 1341 times

dark/Rain
Registered User
Posts: 584
Joined: Mon Mar 19, 2007 4:50 pm

Re: Add BBCode

Post by dark/Rain » Sun Aug 05, 2007 3:56 pm

Great :D
Just curious: are you using the one-line version or the "workaround"?

thegrandstand
Registered User
Posts: 18
Joined: Fri Sep 01, 2006 2:01 pm

Re: Add BBCode

Post by thegrandstand » Mon Aug 06, 2007 12:31 pm

Using the workaround, just because I find it easier entering the data in the code that way.

Cheers :)

Amphor
Registered User
Posts: 88
Joined: Mon Dec 25, 2006 6:18 pm

Re: Add BBCode

Post by Amphor » Fri Aug 17, 2007 6:03 pm

well, looked at the examples, but don't understand it.

How to add brackets () and/or square brackets []?

dark/Rain
Registered User
Posts: 584
Joined: Mon Mar 19, 2007 4:50 pm

Re: Add BBCode

Post by dark/Rain » Fri Aug 17, 2007 11:05 pm

Amphor wrote:well, looked at the examples, but don't understand it.

How to add brackets () and/or square brackets []?
Where and how do you want to use them? (Is the question related to the table BBCode?)

Locked

Return to “[3.0.x] Support Forum”