Load view from database |
Hello!
I'm looking for information to load a View from database. Is there any way? Explample: Code: $this->load->('views_model'); Where $view content something like: Code: id => 1, Thanks in advance
Well, here's what I'm thinking. In your database, you could enter
Code: <html>\n You could have a single universal view file, like this PHP Code: <? php In your controller, you would have something like this PHP Code: $this->load->('views_model'); Before you load the view, you have to convert the variables embedded in the view to actual values. How do you turn $message into the value that is in the variable $message. You could try eval(). It has a bad name, but if it's working on data you have in the database, that data should be safe. You could also try some sort of replace. But really, without spending some time trying to do it, I don't know the complete answer. Sorry.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
You should not do this. Do not use eval especially if users have a way to edit or update the views or you're creating a lot of potential security issues. If you must store views in a DB use the parser library: https://ellislab.com/codeIgniter/user-gu...arser.html
Hey, that's a much better answer. I hadn't learned about the parser library yet. Thanks.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
|
Welcome Guest, Not a member yet? Register Sign In |