Modular Separation. |
[eluser]xtremer360[/eluser]
I'm using the HMVC modular separation for my Codeigniter application and trying to figure out how I can attempt this with my template I have set up. There could possibly be a better way to handle this and I'm not sure of it but if anyone can suggest one I'd be all ears. This is my current file system. Supr as noted as a a folder below is the current theme template I am using. Inside each module controller exists a variable called $view_file. This is the variable this is passed to the body content view page and tells it which view file to display inside my content wrapper in my control panel. What I need to figure out is how to add on a file_exists function to the if statement so that it looks to see if the value for the variable can see if that file exists but not sure how to accomplish this with this HMVC module separation framework. The reason why I need help understanding how to do this is because I don't know how to have it know which module view to look into. I have also included my code for the body content view which contains an if statement to find out which file it needs to load. Code: application/ https://bitbucket.org/wiredesignz/codeig...sions-hmvc
[eluser]Harold Villacorte[/eluser]
If I understand your question correctly you can just add the module name to the data array. Something like this: Code: $data['module'] = 'blog';
[eluser]PhilTem[/eluser]
I'm not sure if I get your question right, either, but HMVC (as long as you're using @wiredesignz HMVC) will always look in the module's view folder for the given view if loaded via $this->load->view(), so there's no need to pass the module name to it.
[eluser]InsiteFX[/eluser]
The Modules::$locations array may be set in the application/config.php file. ie: Code: <?php
[eluser]xtremer360[/eluser]
[quote author="PhilTem" date="1359361569"]I'm not sure if I get your question right, either, but HMVC (as long as you're using @wiredesignz HMVC) will always look in the module's view folder for the given view if loaded via $this->load->view(), so there's no need to pass the module name to it.[/quote] Well something isn't work because it keeps loading my body_unknown which also gets loaded when it can't find the file being requested. This is my body_content.php file. Which is in the application views folder inside of the components folder. I am trying to do a search for the dashboad_view.php folder which is in the application modules in the dashboard module in the views folder of that. Code: /application Code: <!--Body content-->
[eluser]PhilTem[/eluser]
Oh, I see. So, your problem either arises from any of the if-lines. I guess, the problem is the second if. Since all paths are relative to index.php, and you're looking for a view file, it will always fail, unless you have Code: if ( file_exists(APPPATH . 'views/' . $view_file) ) since your code is looking for the view-files located relative to index.php, not the views-folder. See the problem causing line? Otherwise, if this didn't solve your problem, it may be something in your model call, that will always return 0, 1 or something else than (boolean) TRUE.
[eluser]xtremer360[/eluser]
I know its that if statement. The problem is figuring out the difference between having it look in the module's view folder as oppossed to the regular view folder. By this I mean lets say you go to my dashboard which loads the index file just fine with the header component and the footer component and loads the body content component. At this point it'll be in the applications/views/index_view.php file piecing together the template. The problem is if you are loading the dashboard or any of the other modules and pass say the view file variable as 'dashboard_view' then it needs to look for that file somehow in the application/modules folder and hopefully find it there. I'm just lost on how to figure out how to tell it to look there.
[eluser]PhilTem[/eluser]
Aaaah, I finally get it ![]() Then your code should be something like this (haven't tested it, so it may be a little faulty, but should hint you towards the right direction) Code: if ( $this->functions_model->null_check($view_file) === TRUE ) There could be some errors with directory-separators, but I don't have a PHP-environment around, so unfortunately, I cannot test it right now ![]()
[eluser]xtremer360[/eluser]
Why do you have the extra parameters inside the load view command? |
Welcome Guest, Not a member yet? Register Sign In |