Welcome Guest, Not a member yet? Register   Sign In
Some help..
#31

[eluser]adamp1[/eluser]
Its a problem from the first route, because you used regex its catching the call to blog and sending it to main/blog

As said you cant use full regex since it means you can only have one controller. So you need the following
Code:
$route['lists/(d+)'] = 'main/lists/$1';
$route['lists'] = 'main/lists';

// and so on for each controller
#32

[eluser]xwero[/eluser]
The last rout i gave you should be as low as possible in the routes configuration file because it's a very greedy match.
There are a few options where you don't need to fill you routes configuration with all controllers you add, but if you only have a few controllers you can do
Code:
$route['(blog|admin)'] = '$1';
$route['([a-z]+)'] = 'main/$1';
Or you can do it the other way around and identify the methods you want as the first segment
Code:
$route['(lists|method2ofmain)'] = 'main/$1';
$route['(method1ofblog|method2ofmblog)'] = 'blog/$1';
The methods can't have the same name as another method/controller otherwise you can end up in the wrong method/controller.
#33

[eluser]zilverdistel[/eluser]
Great it works, but I have another suggestion for serving up static pages.

I'd make a controller page.php

Code:
class Page extends Controller {
  private $content = '';
  
  function Page()
  {
    parent::Controller();
  }

  function index($id)
  {
    $this->content = $this->load->view($id,'',true);
  }

  function __output()
  {
    echo $this->load->view('html_start','',true);
    echo $this->content;
    echo $this->load->view('html_end','',true);
  }
}

then in your view folder, you can make all the static pages you want.

if you make Page your default controller, you're set.
#34

[eluser]oriceon[/eluser]
And if i say that i receive Page Not Found?

I created this page.php into controller then into view i created html_start end and a about.php page.

I made change in default controller then i acces http://localhost/CodeIgniter/about.html

What is wrong?
#35

[eluser]oriceon[/eluser]
I solved the problem.

1. Into routes.php i added:

$route['default_controller'] = "statice";
$route['scaffolding_trigger'] = "";

$route['([a-z]+)'] = 'statice/index/$1';

2. Into controllers i made a controller named statice.php then i have that code

Code:
class Statice extends Controller {
    private $content = '';
    
    function __construct()
    {
        parent::Controller();
    }
    
    function index($id='statice')
    {
        $this->content = $this->load->view($id,'',true);
    }
    
    function _output()
    {
        echo $this->content;
    }
}

Then into views i have pages: despre.php , statice.php and so on ... then if i load: http://localhost/codeigniter/ it`s load default page: statice.php from view else if i try http://localhost/codeigniter/despre.html it`s load despre.php so that i need! Smile
#36

[eluser]Shahgeb[/eluser]
try to understand segment of codeignitor userguide there is first segment is controller after project name and than comes function name so you must mention controller name
like Blog/list
hopes you want and work




Theme © iAndrew 2016 - Forum software by © MyBB