Welcome Guest, Not a member yet? Register   Sign In
Change url pagination
#11

[eluser]pickupman[/eluser]
Your routes were causing the problem. Try this for your routes:
Code:
$route['congressi/create'] = 'congressi/create';
$route['congressi'] = 'congressi/index';
$route['congressi/index'] = 'congressi/index';
$route['congress/index/(:any)'] = 'congressi/index/$1';
$route['congressi/(:any)'] = 'congressi/view/$1';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

Basically, having a $route['(:any)'] is going to cause you some extra work, because you will need to explicitly give all of your possible routes before it. Routes work in order they are in the file. So you need to make sure they are in the correct order.
#12

[eluser]Girub[/eluser]
in fact if I leave these two lines in the router paging finally see it work Smile


Code:
#$route['congressi/create'] = 'congressi/create';
#$route['congressi'] = 'congressi/index';
$route['congressi/index'] = 'congressi/index';
$route['congress/index/(:any)'] = 'congressi/index/$1';
#$route['congressi/(:any)'] = 'congressi/view/$1';
#$route['(:any)'] = 'pages/view/$1';
#$route['default_controller'] = 'pages/view';


but if decommento this line ...

Code:
$route['congressi/(:any)'] = 'congressi/view/$1';

both before and after as order ...
I click and kept on the second page, I always:

404 Page Not Found
The page you Requested was not found

ok maybe it's a problem bigger than me .. but for the study wanted to understand .. how to make it work ... Smile

I'm trying all possible combinations and orders but does not work ...
this is the problem Smile

Code:
$route['congressi/(:any)'] = 'congressi/view/$1';

I can not find solution ... but not giving up Smile
#13

[eluser]pickupman[/eluser]
Leave the routes as I had shown before in that order. That will be the correct code for it to work. The next thing you need to look at is in your view() method. I believe this is where your error is coming from.

From that method comment out the lines:
Code:
if (empty($data['congressi_item']))
        {
            show_404();
        }

That way you can see what is being returned by your model. You may have an error in your model, so it is returning FALSE causing the show_404() to execute. To help diagnose further as the first line in your view() method

Code:
public function view($id)
    {
        $this->output->enable_profiler(TRUE);
        $data['congressi_item'] = $this->congressi_model->get_congressi($id);

        $data['titolo'] = $data['congressi_item']['titolo'];

        $this->load->view('templates/header', $data);
        $this->load->view('congressi/view', $data);
        $this->load->view('templates/footer');

    }

No when you try and view a record, you will be able to see the actual query being run by your model at the bottom of your page. Check the syntax of the query that is being executed to see why you are not getting any results back from the model.
#14

[eluser]Girub[/eluser]
hello,
first of all I apologize for not having responded sooner but I just been out.

then, spectacular this method:

Code:
$this->output->enable_profiler(TRUE);

Then I commented on the piece that you said, and I realized that the detail could not visualized because it was the wrong link. I now have:

http://localhost/codeigniter/index.php/congressi/index

through the list and it is ok ...

if I click on detail I go to page:

http://localhost/codeigniter/index.php/congressi/92222

and visualize the detail perfectly.



But if I click on the page from the list I am going about this url

http://localhost/codeigniter/index.php/c...i/index/40



Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined index: titolo

Filename: controllers/congressi.php

Line Number: 55

CodeIgniter 2 Tutorial

------------

A PHP Error was encountered

Severity: Notice

Message: Undefined index: titolo

Filename: congressi/view.php

Line Number: 2

----------

A PHP Error was encountered

Severity: Notice

Message: Undefined index: descrizione

Filename: congressi/view.php

Line Number: 3


the query that is executed is actually wrong:


BENCHMARKS
Loading Time: Base Classes 0.0046
Controller Execution Time ( Congressi / View ) 0.0071
Total Execution Time 0.0118

GET DATA
No GET data exists

MEMORY USAGE
3,820,008 bytes

POST DATA
No POST data exists

URI STRING
congressi/index/40

CLASS/METHOD
congressi/view

DATABASE: idea QUERIES: 1 (Hide)
0.0002 SELECT *
FROM (`congressi`)
WHERE `id` = 'index'



error and that always goes in the method and should not view!
thank you very much
#15

[eluser]pickupman[/eluser]
Your routes are still wrong. You can see from the query on the page that url is being route to congress/view/index because the 3rd parameter is being passed to the model is "index". You need to fix your routes to how I had posted above. You can fix your problem until you correct that.
#16

[eluser]Girub[/eluser]
then .. this is my route as you advice

Code:
$route['congressi/create'] = 'congressi/create';
$route['congressi'] = 'congressi/index';
$route['congressi/index'] = 'congressi/index';
$route['congress/index/(:any)'] = 'congressi/index/$1';
$route['congressi/(:any)'] = 'congressi/view/$1';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

thank you very much
#17

[eluser]Girub[/eluser]
then .. this is my route as you advice

Code:
$route['congressi/create'] = 'congressi/create';
$route['congressi'] = 'congressi/index';
$route['congressi/index'] = 'congressi/index';
$route['congress/index/(:any)'] = 'congressi/index/$1';
$route['congressi/(:any)'] = 'congressi/view/$1';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';

thank you very much




Theme © iAndrew 2016 - Forum software by © MyBB