1

I am using yii2 advance template for project and trying to implement theme for backend. To do that i have created a themes folder under backend folder as given below app - backend -- themes --- adminlte ---- js ---- css ---- layouts ----- main.php ---- views - frontend To get the theme url, i am using Yii::getAlias('@backend/themes/adminlte/js/abc.js') and give me full path, /var/www/.... But it gives me 404, page not found error even though file is present there. Please someone help me about file path. It will work fine if i will get path like //themes/adminlte/js/abc.js .

Code of config/main.php

'view' => [
   'theme' => [ 
         'basePath' => '@backend/themes/adminlte',    
         'baseUrl' => '@backend/themes/adminlte', 
         'pathMap' => [ 
            '@backend/views' => '@backend/themes/adminlte', 
         ], 
     ], 
  ],

Code of theme file(main.php)

<?php $themesPath = Yii::getAlias('@backend/themes/adminlte'); 
  <link rel="stylesheet" href="<?php echo $this->theme->baseUrl; ?>
   /bootstrap/css/bootstrap.min.css">
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
Alankar
  • 453
  • 2
  • 10
  • 22
  • Please show the code where you use the alias and the echo /var_dump of the getAlias(...) result – ScaisEdge Oct 01 '15 at 06:00
  • I am using code in main.php under the layouts folder . – Alankar Oct 01 '15 at 06:04
  • If i can see the code i can evaluate otherwise no. – ScaisEdge Oct 01 '15 at 06:06
  • Code of config/main.php 'view' => [ 'theme' => [ 'basePath' => '@backend/themes/adminlte', 'baseUrl' => '@backend/themes/adminlte', 'pathMap' => [ '@backend/views' => '@backend/themes/adminlte', ], ], ], Code of theme file(main.php) theme->baseUrl; ?>/bootstrap/css/bootstrap.min.css"> – Alankar Oct 01 '15 at 16:36
  • I have formated your code. I hope correctly.... – ScaisEdge Oct 01 '15 at 16:53
  • Page not found is the result of a render (or link to a page) seem is not related to this code.. Show the controller code where you try to render your view. (format the code in editing the question please..) – ScaisEdge Oct 01 '15 at 16:57

1 Answers1

0

'baseUrl' => '@web/themes/adminlte',

baseUrl must be in web root

-- app/backend/web/themes/adminlte
---- js
---- css
  • 1
    I dont want to create theme folder inside the web folder. You can check following URL http://stackoverflow.com/questions/25622565/yii2-theme-integration , here they are creating themes folder outside of the web folder. – Alankar Oct 02 '15 at 17:56