CodeIgniter Forums
Parameter passing through routing problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: Parameter passing through routing problem (/showthread.php?tid=78545)



Parameter passing through routing problem - csbb - 02-05-2021

I have a little routing problem, that i can't solve in Codeigniter 4.
I try adding a parameter at deleting list item. But get the following error messages.

> Error message at post routing: Controller or its method is not found:
> \App\Controllers\Userfeed::delete

> Error message at add or get routing: Controller or its method is not found:
> \App\Controllers\Pages::index

the route part:

Code:
[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]//$routes->add('userfeed/(:any)', 'Pages/UserFeed::delete');//this works fine[/font][/size][/color]
[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]$routes->get('userfeed/(:any)', 'Pages/UserFeed::delete');//this works fine[/font][/size][/color]
[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]//$routes->get('userfeed/(:any)', 'Pages/UserFeed::delete/$1');//this is not work, which is the goal[/font][/size][/color]
[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]//$routes->post('userfeed/(:any)', 'Pages/UserFeed::delete/$1');//this is not work[/font][/size][/color]
[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]//$routes->add('userfeed/(:any)', 'Pages/UserFeed::delete/$1');//this is not work[/font][/size][/color]


the controller:

Code:
namespace App\Controllers\Pages;
use App\Controllers\MainCtrl;
...
class UserFeed extends MainCtrl{
....
public function delete($id=FALSE)
    {
        var_dump('wooot?');
        var_dump($id);
    }
}



the view part:
Code:
....
<a class="badge badge-secondary" href="<?php echo base_url('userfeed/delete/'.$rss['id']);?>" >Töröl</a>
....


If need more information let it with me know. 

Thanks your help! Smile


RE: Parameter passing through routing problem - csbb - 02-07-2021

Thank God the problem is solved! Smile

The problem was the forward slash.
This is working now. Smile

$routes->add('userfeed/delete/(:any)', 'Pages\Userfeed::delete/$1');