Welcome Guest, Not a member yet? Register   Sign In
Controller with index($id) method with parameter
#2

(This post was last modified: 08-25-2021, 07:06 AM by captain-sensible.)

i add a route for a "get request like"
Code:
$routes->get('(:any)', 'Pages::showme/$1');

Pages is a class I created and showme is one of class Pages methods.
SO in the first part of your route /listjob/$something is a url which for full would be something like : http://domain.com/listjob/$something

where $something represents a changing end bit of url

but on the right , it doesn't look as if your referencing any class or method

you could directly call method index method on a class if its define

but your route should be something like mine.

Quickest way to play would probably be to edit home controller and add a method



Try this
Code:
below : $routes->get('/', 'Home::index');

add route :

$routes->get('/(:any)', 'Home:test/$1');

Find the controller Home.php in app/Controllers and edit


add appropriately between class { and } :

Code:
public  function  test($something)

{
echo $something;
}


then on your url http://yourapp/vegetables

and see if "vegetables gets returned
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Github  
Reply


Messages In This Thread
RE: Controller with index($id) method with parameter - by captain-sensible - 08-25-2021, 06:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB