How To Render View File With Php Code In Database

Now, I have view file stored in DB and the view file contains some php code like widgets

How can I rend the view file from DB?

Any best practice? I do NOT want to use eval or store the db view data into file, then to render.

Thanks

first of all i have to admit your complete genius, now to your answer if you don’t wanna use eval you code try create_function and call the function

I just want to make content posting more flexible with some special widgets (not all php code).

If there is no way, maybe I have to use the require function.

It’s way too dangerous to treat any of it as PHP code if it’s been posted by a user. In the past, I’ve created a simple tag format for widgets and parsed them using regular expressions.

For example, I allowed the user to create contact forms and lightboxes using the following format:




{contact}

{lightbox:id}



When the page is generated, the {contact} tag is replaced by a dynamic, fully working contact box, and the {lightbox:id} tag is replaced by a block of images (defined by the id) which open in a lightbox.

Thanks Keith, That is what I want. Please help check the following steps and give some suggestions.

  1. The content from frontuser is flushed to a db image file (eg. _dbcontent.php), the {} will be replaced with other tag like prado tag or php code

  2. the _dbcontent.php is rendered Partially using $this->renderPartial(‘xxx/_dbcontent’)

  3. If the contents belong to same view file “exampleview.php”, the $this->renderPartial(‘xxx/_dbcontent’) is contained in exampleview.php. the “_dbcontent” can be any cached files according to different db content.

Am i right? or, there is better solution? Thanks.