CodeIgniter Forums
Segments Question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Segments Question (/showthread.php?tid=25262)



Segments Question - El Forum - 12-06-2009

[eluser]Ducky[/eluser]
I know the usual model is /controller/method/param1/param2/ etc… i created a controller with two functions.
The problem i'm having right now is when i add a parameter to one of the two functions (ex. /controller/method/param1) the complete layout of my page is gone.
When i remove the param. in the url the layout of my page is correct.
This is the first time i'm having such a problem.

thanks for your help

kind regards
ducky


Segments Question - El Forum - 12-06-2009

[eluser]JoostV[/eluser]
Can you post some code, please?


Segments Question - El Forum - 12-06-2009

[eluser]Jamie Rumbelow[/eluser]
Hey Ducky,

The reason why it's going blank (I think) is that you've got PHP errors turned off, so it's just going totally white and unresponsive.

The reason why you're getting errors is because you've not allowed for enough parameters in the arguments list of the controller - you've specified none in the function declaration, for example:

Code:
function index() {
    // code
}

...and CodeIgniter is trying to pass a parameter to it, which in turn is throwing a PHP error and making your application blank. Turn on PHP errors and add a parameter to your controller function and it should fix it!

Jamie


Segments Question - El Forum - 12-06-2009

[eluser]Ducky[/eluser]
this is the controller
Code:
class View extends Controller {

    function View()
    {
        parent::Controller();    
    }
    
    function index()
    {
        //load Model
        $this->load->model('Content_model');

        //Data Request
        $data['content']= $this->Content_model->get_content("NoContentAvailable");

        //load views
        $this->load->view('header');
        $this->load->view('menu');
        $this->load->view('content',$data);
        $this->load->view('footer');
    }

    function hoebestellen()
    {
        echo $this->uri->segment(3);
    //load Model
        $this->load->model('Content_model');

        //Data Request
        $data['content']= $this->Content_model->get_content("HoeBestellen");

        //load views
        $this->load->view('header');
        $this->load->view('menu');
        $this->load->view('content',$data);
        $this->load->view('footer');
    }
}
as you can see i don't use the param. section
i accidently had a parameter added to my url and i noticed my layout disappeared.


Segments Question - El Forum - 12-06-2009

[eluser]Ducky[/eluser]
[quote author="Jamie Rumbelow" date="1260123962"]Hey Ducky,

The reason why it's going blank (I think) is that you've got PHP errors turned off, so it's just going totally white and unresponsive.

The reason why you're getting errors is because you've not allowed for enough parameters in the arguments list of the controller - you've specified none in the function declaration, for example:

...and CodeIgniter is trying to pass a parameter to it, which in turn is throwing a PHP error and making your application blank. Turn on PHP errors and add a parameter to your controller function and it should fix it!

Jamie[/quote]

My page isn't going blank. all the text is available. Only my css layout is gone.(sorry bout being incomplete)


Segments Question - El Forum - 12-06-2009

[eluser]JoostV[/eluser]
You probably used a relative URL to include your css file. Use an absolute URL or set a base href tag.