Welcome Guest, Not a member yet? Register   Sign In
Contents of view files pulled from database
#1

[eluser]Mr. Pickle[/eluser]
To give my CMS more power I'd like to be able to manage the view files from my CMS.

I can think of two options:

1. Have the CMS read the contents of the actual PHP file, edit this content within the CMS and write the new content to the PHP file on the server.

2. Skip having PHP files at all and have all the view-file code read directly from the database

Anyone has experience with one of or both of my options. Maybe a third option?

And if I would like to pull the code/contents from my database, how should I set the up.
Have been thinking about this for a while but couldn't find a way to have the CI parser accept code instead of a file with the code.
#2

[eluser]Rok Biderman[/eluser]
I'm not sure if this is appropriate answer at all, if not, you should elaborate on a couple of things. What exactly do you mean by more power should be the first one. If you wanted to make a static file cms, where you produce html (probably not php) files and then upload it all on ftp, I think you could make do with helpers instead. I would take the content from the db, manipulate them with helpers (when and if needed), then pass the views as variables (pass the third param as true), write them into html files, then use the CI ftp class to upload it to a server.

That way you get a really high performance site (the ratio is something like 2k requests for html, 1,3k for pure php, and 950 for CI, for comparison), which runs on any server but can still be dynamically updated. Hosted admin of a non hosted webpage, in a sense.

You could also take a look at another file based cms Lack as you might pick up a few ideas there, but be sure to leave some feedback to Boris Wink
#3

[eluser]Unknown[/eluser]
i think you should elaborate about more power, what do u exactly want to do ?
#4

[eluser]Mr. Pickle[/eluser]
What I want to do is have the contents of my views not in a file.
I currently have view files not containing php (using the dwoo parser so view files contain dwoo tags)

For example: normally if I want to have the navigation view with some data (array $data) I have the following code in my controller:
Code:
$this->load->view('navigation.php', $data);

Now, what I want is to have the exact same content I now have in navigation.php in a database record. This way I can easily edit this with a web page.

So I basically want:
Code:
// $navigation containing exact the same contents as navigation.php but as string (retrieved from the db)
$this->load->view($navigation, $data);

I now the above code is not possible (as far as I now) but it gives an idea of what I want.
#5

[eluser]Nick_MyShuitings[/eluser]
I think you're making this harder than it needs to be... there is no need to modify CI in the slightest to store the entire page or page content in the database.

Code:
$stuff = $this->your_model->get_your_shit();
$this->load->view('echoes_the_stuff',$stuff);

So go ahead and make a view that just echoes the one variable passed into it, and then load whatever you want from your database into that one variable....
#6

[eluser]Mr. Pickle[/eluser]
Hi Nick,

That would -by my knowlegde- just echo the content from the database, which means that the content in the database should be static.

What I want is to be able to include (dwoo) tags there. Lets say:

Code:
{foreach $items item}
    {$item.name}
{/foreach}

So the code from the database should be parsed first.

Or is this already possible / working with the method you describe?
#7

[eluser]Nick_MyShuitings[/eluser]
You'd need either a dwoo parsing library/helper etc... but in that case it'd be one more line:

Code:
$stuff = $this->your_model->get_your_shit();
$parse = $this->dwoo_parser->parse($stuff);
$this->load->view('echoes_the_stuff',$parse);

I'm not familiar with dwoo, so I don't know if there are any php parsers already converted to libraries... but its pretty easy to do.
#8

[eluser]InsiteFX[/eluser]
CodeIgniter has a built in Parser Class read the CodeIgniter User Guide!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB