Closed shaunandrews closed 13 years ago
First - glad you're enjoying Ocular. I almost can't imagine working without it anymore. :)
The times I've done things like this, I haven't needed the blocks feature. Instead I've just used CI's standard:
$this->load->view('single_entry', $entries)
And looped inside of the 'single_entry' file.
What you're recommending make sense, though I'm not sure that I see the need to complicate things by having Ocular perform the loop, when a simple PHP (or even a template parser) call will do the trick.
I will add in the ability to pass data to the block, though.
Version 2.13 (available in just a few minutes) includes two items for you:
First: you can now pass an array into the block() method.
Second: A new function, called themed_view(), which acts like a helper function, just like the breadcrumb function. It takes the path to a view, relative to the theme folder, and a data array, then renders the view based on the current theme. This was a function that I needed recently while working on a mobile version of a site where blocks felt too heavy handed.
That should handle most of your needs, right there. Let me know if something broke. I ran some quick tests and everything appears to be working, but you never know. :)
Awesome stuff, Lonnie!
However, the updates to the block don't seem to do what I need—I'm passing an object to the block, but it appears that it will only work with an array. In any event, I took your original advice and use the Loader class to call the view and passing an object. I originally tried this, but was unaware that this ran a PHP extract, and output the object fields as variables, So $object->field becomes $field. Cool stuff.
Again, thanks for the great work!
Hopefully the title here isn't too confusing, and this is more a request than an issue.
Right now, Block's can be rendered using data provided by the Controller, but not by the parent View. For instance, I have the following:
I was hoping to be able to extract the HTML for a single entry, and use it as a Block. I was hoping that I could updated my View to be:
With my single.php view (partial?) containing:
However, it appears that the $entry variable isn't passed to the block. Not sure if I'm missing something.
It would be really great to have support for something similar to rails collections, using the format:
Anyways. Great work! I'm loving Ocular!