Jump to content
Sign in to follow this  

The most appropriative way of using data formats

Recommended Posts


The task is common: saving and displaying publications at the website.

The information I enter is not only pure html but also some special shortcodes like BB-code.

For example:

<p><a href="[page:1]"></a>
[b]Strong text[/b]
[img:1] <-- some img I attached to this article

Obviously I have to save this information as It is, so it would be the same for editing process

But I can't start regexp search for populating all this data per every request for displaying the data.

So I can use a cache, though of couse I would have a double disk capacity taken with this approach.

But how to do it in a better way?

1) keep additional column in table for this article's body field?

id  title  body body_processed
           [b]     <b>

2) use some additional cache table, and left join it all the time I get data from Article


3) Is there any other fortunate way to solve this task



p.s. I am familiar with drupal and it is using something like 2) approach. But now I am not using cms and the framework I am using (Yii2) leaves this problem up to an end developer. Though it is a common problem for every web site which has a content managment into it.


Share this post

Link to post
Share on other sites

Don't make it more complicated than it needs to be. Add a column to whatever table you're using to hold the HTML-ready version, alongside the raw BBCode version. Yes, it doubles disk space, but disk space is cheap and plentiful while your time is not.

Share this post

Link to post
Share on other sites

 ckeditor or tinymce are not text formats.

They are the editors which suggests you are using full html format.


My question is about more complicated things like wordpress shortcodes. When you might need to assosiate some js or css code with a shortode and you can't insert this js code like inline to cached version of text, because jquery library are included lower at the page...

Edited by web_craftsman

Share this post

Link to post
Share on other sites

To me saving it as it's intended output is the best way to go about it. Which is why I said the editor.

If you don't want to save as html you can do the bbcode addon for ckeditor.


There is even bbcode parsers made for yii2.

Unless you plan on creating everything from scratch and make another yii2 parser like the others.


On the topic when need to include js or css into the cms, this is why any mature cms makes plugins or modules.

Only cache html that will not be live or user data.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.