Welcome Guest, Not a member yet? Register   Sign In
How i can executed my controller in the url
#1

Hey,

i have choosing today the way to coding with CodeIgniter. So i'm a newbie in frameworks, but the framework looks not so hard. I have tried the first Tutorial "static page". Now if i want to call the site in the url i get everytime the error, that this site doesn't exist. I don't know why this is. 

A url looks after the tutorialsite so : /[controller-method]/[arguments]http://example.com/[controller-class]/[controller-method]/[arguments]

I executed all at xampp local. And if i executed it like this i get everytime the error.

My Path to the framework folder is this :http://localhost/php/frameworks/codeigniter/
Now if i want to executing my controller with the method the url must be like this: http://localhost/php/frameworks/codeigniter/pages/view

But if i load this url i get everytime the error, that this object can't get found.

The Code is:


PHP Code:
<?php

class Pages extends CI_Controller{

    public function 
view($page 'header'){

        
// APPPATH = application folder

        
if(!file_exists(APPPATH "views/templates/" $page ".php")){
            
show_404(); // ->shows 404 error site
        
}

        
$data = [];

        
$data["title"] = ucfirst($page); // ucfirst sorgt dafür das der erste buchstabe ein Großbuchstabe ist


        //seite laden/aufrufen
        
$this->load->view("pages/header/"$data);
        
$this->load->view("pages/footer/"$data);

    }



My 2 view-datas looks so:

header.php
PHP Code:
<!DOCTYPE html>
    <
html>
        <
head>
            <
title><? echo $title?></title>
        </head>
        <body>
            <p>Titel dieser Seite lautet <? echo $title; ?></p> 

footer.php
PHP Code:
        <p>copyright @stef</p>

    </
body>
</
html

Hope you can help me.

Stef
Reply
#2

I have solved id. The problem was the missing routes.
Reply
#3

Did you setup your base_url in the config.php file?
Did you setup your routes in the routes.php file?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB