Jump to content

The most appropriative way of using data formats


web_craftsman

Recommended Posts

Hi.

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
</p>

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?

Article
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.

 

Link to comment
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.

Link to comment
Share on other sites

  • 1 month later...

 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
Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.