[eluser]Kilroy[/eluser]
Hello!
I recently discovered CodeIgniter, and for the last couple of days I've been playing around a bit with it. My plan is to find a nice php framework that allows me to separate presentation, data and logic and eventually migrate an entire website to it.
However, I encountered problems right away. For creating the main menu, I have a system where the "current" link gets a class tag, like this: <a href="something.php" class="active">Some link</a>. This is based on the filename, and the logic looks something like this: if($filename == 'something.php') echo 'class="active';
Now, I wouldn't know how to do this with CI, since it always loads from index.php. My first idea was to compare it to the first segment of the URI instead of the filename, but that wouldn't work either, since having a default controller permits URIs without a first segment.
My second idea was to set a variable in the controller, so the view will know which controller called it. I haven't tried this yet, but I am sure it would work, even though it would not be a very elegant solution. How do you solve this?
Anyway, on to my next question. I have quite lots of things that simply need fetching from a database. Say I want to get the content-field from a table called 'news' where the id is 5. Right now, I do it this way (don't mind the tinymce-code):
Code:
$row = $this->db->where('id', 5)->get('news', 1);
$row = $row->row();
$data['news'] = $this->tinymce->echo_tinymce($row->content);
It gets sort of repetative if you have 5-6 (or even more) of these per controller.
Is there a better way of accomplishing this?
Of course there aren't only drawbacks with CodeIgniter, it would probably be a huge lift for my administration system.
Just a last question. If I have tons of data that I need to pass to the view, is passing it through $this->load->view('someview', $data); the only way? It seems like this is a huge waste of memory.
Kilroy