View Single Post
Old 06-17-2010, 08:13 PM   #7 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Haha, it's solved for the moment but not the way I wanted.
I have an HMVC framework with modules, I wanted so when I load a view, it will first check if the view exists in the current module - IF the view was loaded from a module - and then if not found there check the regular application/views/ folder for the view-file.

Kinda like this:
modules/welcome/controllers/welcome.php
PHP Code:
View::factory('website/index'); 
That will check modules/welcome/views/website/index.php, if found, render it.
If not found, check application/views/website/index.php, if found, render it.
If not found, check all other modules views directories, if found, render it.
If not found, generate error message.

On the other hand, if I do like this:
application/controllers/welcome.php
PHP Code:
View::factory('website/index'); 
It will check application/views/website/index.php, if found, render it.
If not found, check all modules views directories, if found, render it.
If not found, generate error message.

All of that is quite simple, takes some work but I can make that work.
The thing that complicates it is that I want to be able to load a view from within a view.

Like so:
modules/welcome/views/website/index.php
PHP Code:
<?php echo View::factory('footer'); ?>
It will check modules/welcome/views/footer.php, if found, render it.
If not found, check application/views/footer.php, if found, render it.
If not found, check all other modules views directories, if found, render it.
If not found, generate error message.

I think you get the point..
So somehow I need to check if the factory() call came from a class, if so, check which class, get the name, get the location. If not from a class - but from a viewfile - get the location of that viewfile.
__________________
Tanax is offline  
Reply With Quote