Welcome Guest, Not a member yet? Register   Sign In
Ocular 2.0 - Template Library for CI with mobile templating
#1

[eluser]kilishan[/eluser]
I know that a number of you have used Ocular before. Well, after bumping into a couple of design headaches with it, I rewrote it. It's much more focused now on what it should be doing: rendering the page as simply, powerfully, and flexibly as it can. Here's the highlights of the new version:

Block-based Layouts Rendering of partials is best handled by CI's own views, so it uses Blocks instead. These are a more flexible version of views, where a default view can be set if none exists, but can be overridden. This allows you to setup a single layout to handle your entire site.

Theme Engine that will check the user agent and allow you to specify any number of Themes to be used for specific user agents. For example, you can specify 'Apple iPhone, Apple iPod Touch' to render a 'iphone' theme. Ocular searches for the view first in your specified theme, and, if it doesn't exist, falls back to the default theme. You can use this to create multiple themes for your site also.

Extension Handling allows you to specify any number of file extension types for your views. This allows you to write your views in Mardown, or Textile and have it converted to HTML automatically. You could also use this system for custom filtering of the text before display (bad words filter, etc).

Auto-Loading Views still works the same way - views are loaded based on the controller/function being called.

Ajax check (thanks to Jamie's wonderful code) that tells you if the request was made through an AJAX call or not.

and more...

Full documentation is not available yet, but I'll be working on it daily. The source code is thoroughly commented, though, and it should be relatively easy to get going with it.

If you've used Ocular in the past, please note this is NOT a drop-in replacement for the 1.x versions, and is not recommended as a replacement in existing applications.

Matchbox and HMVC users: Ocular does not directly support you, though I tried to make it as painless as possible. It should just require a very small change to your Loader.php files to get them working together, and the change is clearly marked in the MY_Loader.php file that ships with Ocular.

Learn more and download here at http://igniteyourcode.com/ocular
#2

[eluser]Phil Sturgeon[/eluser]
I couldn't find the change to enable modular support, but it is always possible I am being a pillock.

Also, the ajax detection code is not written by Jamie. Derek originally posted it on these forums and I have seen it floating around in various places. Credit where credit is due. Tongue
#3

[eluser]kilishan[/eluser]
[quote author="Phil Sturgeon" date="1261001659"]I couldn't find the change to enable modular support, but it is always possible I am being a pillock.

Also, the ajax detection code is not written by Jamie. Derek originally posted it on these forums and I have seen it floating around in various places. Credit where credit is due. Tongue[/quote]

Didn't realize Derek posted that. First time I saw it was on Jamie's extended Controller. Good to know!

As for the Loader changes, there was a small change to the _ci_load function that basically just checks if Ocular is loaded and returns false if the view is not found. While there is the potential for some issues here (since _ci_load is used by all of the load functions) it appears that this particular portion of the code is only used for the views and my small tests with the new Ocular haven't revealed any other issues. Here's the relevant code:

Code:
if ( ! file_exists($_ci_path))
        {
            ///@ OCULAR CHANGES @///
            
            // Is Ocular loaded?
            if (class_exists('Template'))
            {
                return false;
            }
            ///@ END OCULAR CHANGES @///
            
            show_error('Unable to load the requested file: '.$_ci_file);
        }

I didn't want to go this route - hacking core - but I needed Ocular to work both with and without Matchbox, etal. since I use it some sites and don't on some other smaller projects. This meant that the $this->load->view() was the solution required. And, it worked fine until I implemented the themes which have to check if the file exists in the overriden theme, then try again in the default theme if it's not there. When you add in modules that would allow the views to be pretty much anywhere, then this seemed like the best solution.

Phil, I know you've used Matchbox quite a bit in the past so if you have any insight here for a better way to handle it, please post. I'd love to get rid of the MY_Loader file. Smile
#4

[eluser]kilishan[/eluser]
Oops. I forgot to mention last week, but the Beta 2 version is live, fixing a few (stupid) errors and now with complete docs.

You can find it at: http://igniteyourcode.com/ocular.
#5

[eluser]Deep Arora[/eluser]
I am not able to make ocular work with HMVC, even after making the suggested change. Could you pls help in this thread:

http://ellislab.com/forums/viewthread/176727/

TIA




Theme © iAndrew 2016 - Forum software by © MyBB