web_craftsman Posted April 24, 2015 Share Posted April 24, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/295816-the-most-appropriative-way-of-using-data-formats/ Share on other sites More sharing options...
requinix Posted April 24, 2015 Share Posted April 24, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/295816-the-most-appropriative-way-of-using-data-formats/#findComment-1509799 Share on other sites More sharing options...
web_craftsman Posted June 8, 2015 Author Share Posted June 8, 2015 any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/295816-the-most-appropriative-way-of-using-data-formats/#findComment-1513456 Share on other sites More sharing options...
requinix Posted June 8, 2015 Share Posted June 8, 2015 Guess not. Quote Link to comment https://forums.phpfreaks.com/topic/295816-the-most-appropriative-way-of-using-data-formats/#findComment-1513489 Share on other sites More sharing options...
QuickOldCar Posted June 8, 2015 Share Posted June 8, 2015 Use a text editor like ckeditor or tinymce Quote Link to comment https://forums.phpfreaks.com/topic/295816-the-most-appropriative-way-of-using-data-formats/#findComment-1513493 Share on other sites More sharing options...
web_craftsman Posted June 9, 2015 Author Share Posted June 9, 2015 (edited) 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 June 9, 2015 by web_craftsman Quote Link to comment https://forums.phpfreaks.com/topic/295816-the-most-appropriative-way-of-using-data-formats/#findComment-1513498 Share on other sites More sharing options...
QuickOldCar Posted June 9, 2015 Share Posted June 9, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/295816-the-most-appropriative-way-of-using-data-formats/#findComment-1513499 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.