简体   繁体   中英

Render a view in slim does'nt show the view with its css and bootstrap

I'm new in slim framework and in PHP 5, I've copied a template folder download from the internet on my folder '/Template' which is the 'template.path' and I've renamed the folder download '/Default' . When I want to render the view to a page from 'Default' folder I've written:

 $app->get('/auth', function() use ($app) {
        $app->render('/Default/pages/examples/lockscreen.html');
    });

When I go to http://localhost/Site/index.php/auth , it shows me the content without its CSS and its Bootstrap.

And in lockscreen.html, the link to the CSS and the bootstrap file are written like that:

<link href="../../dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

and this is the architecture of the folder /Default :

  • /Template
    • /Default
      • /bootstrap
      • /build
      • /dist
      • /pages
        • /examples
          • lockscreen.html

It's hard to give you a correct answer without knowing your site's complete directory structure, but the reason your template file is not pulling in the .css files is because the generated page is (normally) relative to your site's public (web) root, not to the template file. So, for example, if your web root is /Default, the css includes in the template should be:

<link href="/dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />
<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

It would help to know where your index.php file is located within the directory structure - it should be located in your site's public root folder.

I've solved it! It's about the root to the css file and the bootstrap file and this is what i've done :

<link href="./Template/Default/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="./Template/Default/dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM