Welcome Guest, Not a member yet? Register   Sign In
URL parameters in CodeIgniter 4 Not Working
#1

I tried to access an id from a URL

http://localhost:8080/CI4/public/details/1

Routes.php
Code:
$routes->get('details/(:any)', 'Car::details/$1')


Car.php (controller)

Code:
class Car extends BaseController
{

    public function details($id)
    {
        $carsModel = new carsModel();
        $query = $carsModel->findAll();

       

        $data = [
            'title_meta' => view('partials/title-meta', ['title' => 'Cars']),
            'page_title' => view('partials/page-title', ['title' => 'Vehicles', 'li_1' => 'Home', 'li_2' => 'Cars']),
            'carsList' => $query
        ];

        return view('details', $data);
    }

Partials head where css is referenced
Code:
    <!-- preloader css -->
<link rel="stylesheet" href="assets/css/preloader.min.css" type="text/css" />

<!-- Bootstrap Css -->
<link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
<!-- Icons Css -->
<link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
<!-- App Css-->
<link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
i can get the ID on details page , but the CSS and page layout not loading and the url become like this

http://localhost:8080/CI4/public/details...ap.min.css
instead of
http://localhost:8080/CI4/public/assets/...ap.min.css
Reply
#2

Use base_url().
https://codeigniter4.github.io/CodeIgnit...l#base_url
Reply
#3

PHP Code:
<?= base_url('assets/css/bootstrap.min.css');?>
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB