Welcome Guest, Not a member yet? Register   Sign In
another routing problem :) please help
#1

Hi,
PHP Code:
  
I create Blog, and in Blog Controller I hane method index, who select all posts and method 'wpis':

 public function wpis($id)
    {
      $dzis = Time::today('Europe/Warsaw', 'pl_PL');
      $data['menu']=1; 
      $modelw = new Blog_m();
       
      if(isset($id))
          {
            $data['id']=$id;
          }
          else
          {
            return redirect()->to('blog');
          }

etc...
And in Routing I put:
PHP Code:
$routes->get('''FRONT/Page::index');
$routes->get('/''FRONT/Page::index');
$routes->get('blog''FRONT/Blog::index'); - work
$routes
->get('wpis/(:num)''FRONT/Blog::wpis/$1'); - -this not works :(
"

Controller or its method is not found: \App::index
"

but, if I remove $
PHP Code:
$routes->get('wpis/(:num)''FRONT/Blog::wpis');

PHP Code:
Too few arguments to function App\Controllers\FRONT\Blog::wpis(), 0 passed in 

$routes->ge
Reply
Reply
#3

(This post was last modified: 02-12-2022, 11:30 PM by ikesela.)

there is no route for /wpis , existing route is /wpis/{num}

alternatively can add this for default route:

$routes->get('wpis', 'FRONT/Blog::wpis');

change function to:

public function wpis($id = 0) // for default route
Reply
#4

(02-12-2022, 10:58 PM)iRedds Wrote: https://forum.codeigniter.com/thread-805...#pid391775
Thanks, but unfortunelly:
PHP Code:
$routes->get('''FRONT\Page::index');
$routes->get('/''FRONT\Page::index');
$routes->get('blog''FRONT\Blog::index');
$routes->get('wpis/(:num)/(:segment)''FRONT\Blog::wpis/$1/$2');

And 
ofcouse add second var info function, result this same :( 404 
Reply
#5

Namespace uses a back slash \ not a forward slash /

FRONT\Blog::wpis/$1
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

for testin I do:
public function wpis($id=0)


and add in Routes
$routes->get('/wpis', 'FRONT\Blog:wpis');
$routes->get('/wpis/(:num)', 'FRONT\Blog::wpis/$1');

now, in url when I go in:
https://url/wpis

i get:
ErrorException
Undefined array key 1
SYSTEMPATH/Router/Router.php at line 430

strange things

below stil not works
$routes->get('/wpis/(:num)', 'FRONT\Blog::wpis/$1');
Reply
#7

(This post was last modified: 02-13-2022, 06:21 AM by Kordianz.)

my folders structure:
[Image: structure.png]
Reply
#8

WORRRKSS!!!

$routes->get('/wpis/(:num)', 'Front\Blog::wpis/$1', ['namespace' => 'App\Controllers']);
Reply
#9

This is the default namespace.
$routes->setDefaultNamespace('App\Controllers');
Reply
#10

Yes, but work with this, without not.
Hmm, maybe: $routes->setDefaultNamespace('App/Controllers'); herer is wrong slash
Reply




Theme © iAndrew 2016 - Forum software by © MyBB