Reputation: 1065
I've an application build in Yii2 framework, and I've develop the application in backend side, but know I want to copy them become a module.
backend
--modules
--pstk
--controllers
--ValidationController.php
--DefaultController.php
--InterviewController.php
--StudentController.php
--SiteController.php
--UsersController.php
--models
--Validation.php
--Interview.php
--Student.php
--Users.php
--views
--validation
--_form.php
--view.php
--index.php
--update.php
--create.php
--interview
--student
--users
--Module.php
--web
--css
--manual_general.css
--js
--upload_header.js
--style
For example I've successfully run view.php
from the module in browser, but the module can't access the .css
and .js
from backend/web/
.
So the view displayed, but it's view mashed-up and all button didn't do any action when clicked.
manual_general.css
and upload_header.js
from backend/web/
? and how I can solve this problem?Any help, will be appreciated. Thanks :)
This is the code in mi view.php to connect to .js
and .css
<link rel="stylesheet" type="text/css" href="../../../../web/css/manual_general.css">
<script type="text/javascript" src="../../../../web/js/upload_header.js"></script>
Upvotes: 0
Views: 68
Reputation: 535
Try using yii\helpers\Url::to, like:
<link rel="stylesheet" type="text/css" href="<?= Url::to('@web/css/manual_general.css') ?>">
<script type="text/javascript" src="<?= Url::to('@web/js/upload_header.js') ?>"></script>
Alternatively, in view.php you may do (assuming $this is your View instance):
<?php $this->registerCssFile('@web/css/manual_general.css'); ?>
<?php $this->registerJsFile('@web/js/upload_header.js'); ?>
Upvotes: 1