lonnieezell / Ocular-Template-Library

A template/layout library for CodeIgniter
http://igniteyourcode.com/ocular
88 stars 23 forks source link

HMVC #9

Closed karellm closed 14 years ago

karellm commented 14 years ago

Would you mind providing some info to make Ocular work with HMVC plz?

lonnieezell commented 14 years ago

I have never tried using the HMVC, only Matchbox and Modular Separation. If it works the same way as those, and I believe it does, the change should be a simple one. And that change should only be needed if you are using the themes feature of Ocular.

In HMVC's MY_Loader file (I'm assuming it has one, that's how the others work....) check to see if it overrides the _ci_load() method. If it does, you will need to integrate a very small change that I implemented in that method that simply checks to see if Ocular is loaded and, if so, returns false when a view file is not found.

Ocular, itself, uses $this->load->view() exclusively to render views so that it would be as compatible as possible with third party HMVC-type plugins.

There may be more to it then that, I can't say. :) But that should theoretically be all that is needed. It all depends on how the HMVC library works.

I'd love to hear if you get it working and what changes you made to make that happen. If you want to fork the code and implement a change there, send a pull request and I'll include it in the official repo.

karellm commented 14 years ago

Thanks for the help. Ocular loads but it looks for the view at the wrong place : Current View = ../modules/welcome/controllers/welcome/index Instead of ../modules/welcome/views/welcome/index

The result is an error (header already sent by Template.php)

Do you have an idea?

lonnieezell commented 14 years ago

I do have one idea, but it might cause a problem if you're using controllers within those modules that are in subfolders, like module/module_name/controllers/admin/controller.php. If you're not doing that, you can try the following fix:

On line 237 of the latest version, remove the directory call, so it should go from this:

$this->current_view = $this->ci->router->directory . $this->ci->router->class . '/' . $this->ci->router->method;

to this:

$this->current_view = $this->ci->router->class . '/' . $this->ci->router->method;

karellm commented 14 years ago

It didn't work, but I put (and it worked): $this->current_view = '../views/' . $this->ci->router->class . '/' . $this->ci->router->method;

Is there a way to do it in a cleaner way though?

karellm commented 14 years ago

And why do you echo the view path? I don't get it and I don't see any config variable for dev/prod env that would turn it off. What is it made for?

Thank you for you help!

lonnieezell commented 14 years ago

I'm not sure of a cleaner way to do it then what you have there. If it's working for this project, then great! :)

As for echoing the view path... my bad. I was trying to debug something and forgot to delete it before uploading. Feel free to rip it out of there.