Jump to content

Redo/Rebuild BBCode System


Guest Luke

Recommended Posts

(Note: This also increases performance of the forum by reducing, or even removing, custom bbcode being done on the fly for each post and signature when viewing a topic, etc. Also integrates Custom BBCode and Built in BBCode into one system.)

One of biggest concerns I have with IPB is built-in BBCode and Custom BBCode (in adminCP). You really have severly limited control over the custom bbcode, and zero (if not minimum) control over the built in BBCode.

The biggest problem with Custom BBCode is it's done on-the-fly. This means that every time a post is loaded, it's done on signatures and posts, and each code is parsed whether it's present or not. Plus, custom bbcode plugs in values into simple html, and you really cant do much with it besides add existing html elements (you cant do something special like a code highlight).

A while back I designed a "Dynamic BBCode" add-on which allowed me to specify a custom plugin/module (class) instead html (where you plugin {content} and {option}). This allows me to do special things like pull players stats and make a special signature. It allows you to parse the content of a code how ever you want.

What I propose is strip out the built in bbcode and custom bbcode system and replace it with a single bbcode customization in adminCP where you can modify existing bbcodes, or add your own. Most improtantly you have the bbcode, by default, parsed when a post is made, having no code processed on-the-fly.

What it has, and what it looks like

The Index:

When you look at the BBCode list index, it looks exactly the same with Title, and Example, Edit/Delete options.

Add/Edit BBCode:

Title: [____________]
Description: [____________]
Example: [____________]
Tag: [ [____] ]
Signature: [X] Yes [ ] No
Posts: [X] Yes [ ] No
PMs: [X] Yes [ ] No
Single Tag: [ ] Yes [ ] No [ ] Both
On-The-Fly: [ ] Yes [X] No
HTML or Script: [X] Script [ ] HTML
Script: ./sources/bbcode/bb_[_______].php
Custom BBCode HTML
[


]

- When Script is chosen, Custom HTML is greyed out. When html is chosen, Script is greyed out
- If option is used in html (detected when submited) then option is on. If not, it's off)
- [tag=option]content[/tag] - is only used for html. BBCode with scripts use the [tag option1="value" option2="value" ... ]content[/tag] format.
- Tags using simple HTML are processed first. Then any remaining tags in text are looked at and tag name checked against remaining bbcodes. If exists, strip out tag name, content, and options and send to script/class for processing. A single bbcode plugin/script/class can be used for multiple bbcodes. A switch is used in main function.
- You can return an error to the editor.
- An "On The Fly" option does exist for those that absolutely need it. Can be used to bring up unique content every refresh. Most people woulnt need it, but some might. Disabled if script isnt being used.
- For the editors sake, you can store it in the db like this:

<!---BBC[tag option1="value" option2="value" ...]---><!---CONTENT[old content]--->new content<!---[/tag]BBC--->



You only would have the "CONTENT" thing if the inside content has changed. If it remains the same, dont include it and use the old content when returning to edit. It might be a good idea to strip out content when viewing it. Would only need to do it ONE time after building the posts, not on the individual posts themselves.
- "Single Tags" are support for tags like [tag option1="" /] instead of just [tag option1=""][/tag]. "Both" would be good for img so you could do [img src="url" /] or [img ]url. Single tags must end with the trailing slash before the "]".

This could be easily done without distrupting people's existing posts. For those that have custom bbcode, you could have a tool that goes through the posts and processes them (that are not on-the-fly).

Anything else that might be loaded on-the-fly should also be done when the post is made :)

Comments appreciated.

Link to comment
Share on other sites

+1 :)

A while back I designed a "Dynamic BBCode" add-on which allowed me to specify a custom plugin/module (class) instead html (where you plugin {content} and {option}). This allows me to do special things like pull players stats and make a special signature. It allows you to parse the content of a code how ever you want.

Very good idea! :D
Link to comment
Share on other sites

  • 1 month later...

I like the idea too, but the implementation is difficult.

You can't parse custom code at post time, or every time you need to add/edit a bbcode, you would need to rebuild post content, which can take a long time.

As a small aside, some improvements have been made to the parsing routines in 2.2 in terms of performance, I'm not entirely sure if these will affect custom bbcode at topic view time, but it shouldn't be that big a CPU burden unless you have tons of custom bbcodes.

I do agree some further options could be added, but the current system is designed to be simple and easy to use :)

Link to comment
Share on other sites

Edited cause I re-read.

Honestly, I think that this is ok. I mean, if you change up a BBcode that other posts may have used, you do not necessarilly need to care about updating previous posts unless they were causing the forums to screw up. If users happen to edit their old post using this changed bbcode they would then be parsed using the updated version. And in the case that something was broken you could run the post rebuilder.

I especially like the ability to do scripting with this. :D :D ++

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...