Welcome Guest, Not a member yet? Register   Sign In
Load Controller Into View Question
#1

[eluser]razerone[/eluser]
Hi.

I have HMVC. hmvc works same as codeigniter but you can make things into modules.

I would like to know I have created a module called slideshow it has its own controller. is it possible to echo out the controller/view to a view page.

I am just trying to make it so can module things makes easy to maintain

What stages do I need to take.

my controller is called slideshow.php same as my view which is slideshow.php
#2

[eluser]noideawhattotypehere[/eluser]
Code:
<?php echo Modules::run('controller/method', $param1, $param2, ...) ?>
#3

[eluser]razerone[/eluser]
[quote author="noideawhattotypehere" date="1382509548"]
Code:
<?php echo Modules::run('controller/method', $param1, $param2, ...) ?>
[/quote]


Is this corect

views / home.php

<div id="slideshow">
&lt;?php echo Modules::run('slideshow/slideshow', $param1, $param2, ...) ?&gt;
</div>


application:
modules / slideshow / controller / slideshow.php
modules / slideshow / views / slideshow.php


Is there a you tube video on it on how to call it. can't seem to find right one.
#4

[eluser]noideawhattotypehere[/eluser]
controllerS/slideshow.php <--- plural form!
Code:
class Slideshow extends MX_Controller {

public function _remap() { //we dont want it to be accessible via url, do we?
        show_404();
    }

public function show_slideshow() {
echo $this->load->view('slideshow', TRUE);
}
}
in your view, wherever you want that slider
Code:
&lt;?php echo Modules::run(‘slideshow/show_slideshow’) ?&gt;
#5

[eluser]razerone[/eluser]
[quote author="noideawhattotypehere" date="1382511214"]controllerS/slideshow.php <--- plural form!
Code:
class Slideshow extends MX_Controller {

public function _remap() { //we dont want it to be accessible via url, do we?
        show_404();
    }

public function show_slideshow() {
echo $this->load->view('slideshow', TRUE);
}
}
in your view, wherever you want that slider
Code:
&lt;?php echo Modules::run(‘slideshow/show_slideshow’) ?&gt;
[/quote]

Did it that way but got error on page and removed styling.very strange.
#6

[eluser]noideawhattotypehere[/eluser]
What was the error?
change ‘ to ' in &lt;?php echo Modules::run(‘slideshow/show_slideshow’) ?&gt;
#7

[eluser]razerone[/eluser]
[quote author="noideawhattotypehere" date="1382520600"]What was the error?
change ‘ to ' in &lt;?php echo Modules::run(‘slideshow/show_slideshow’) ?&gt; [/quote]

Fatal error: Class 'Slideshow' not found in /home/cws01/public_html/application/third_party/MX/Modules.php on line 105

<div id="slideshow">
&lt;?php echo Modules::run('slideshow/show_slideshow');?&gt;
</div>

&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');



class Slideshow extends MX_Controller {



public function _remap() { //we dont want it to be accessible via url, do we?

show_404();

}



public function show_slideshow() {

$this->load->view('slideshow', TRUE);

}



}
#8

[eluser]noideawhattotypehere[/eluser]
Where is your controller Slideshow located? MODULESFOLDER/slideshow/controllers/slideshow.php?
#9

[eluser]razerone[/eluser]
[quote author="noideawhattotypehere" date="1382522150"]Where is your controller Slideshow located? MODULESFOLDER/slideshow/controllers/slideshow.php?[/quote]

All modules are in

application/modules

example

application/modules/slideshow/controllers/slideshow.php
application/modules/slideshow/views/slideshow.php

Most of stuff can work out but it just something strange. I though it would be best to have it in module format rather than direct on home views so when it is in modules easier to manage if something gone wrong




Theme © iAndrew 2016 - Forum software by © MyBB