Answer the question
In order to leave comments, you need to log in
How to implement the connection of additional css and js in PHP frameworks?
Friends, with your help, I have made great progress in the knowledge of this new world .. But questions, which is logical, as new words are introduced into my brain, sometimes arise ... and sometimes very obvious ... Kondovo, I can solve them, but I would like to of course "according to science", "so as not to film search" (c).
A very simple question...
What is the best way to implement adding additional css styles and scripts to some pages?
Let's say there is a common template - layout.
Make an empty $add_styles and $add_js label in it and pass them when rendering?
You end up with something like this...
<?php if(isset($add_styles)): ?>
<?php echo$add_styles; ?>
<?php endif; ?>
<?php if(isset($add_js)): ?>
<?php echo$add_js; ?>
<?php endif; ?>
and in the controller:
$add_styles='';
$this->view->assign('add_styles',$add_styles);
echo $this->view->render('index');
Hat?
I have not yet found how this is done in Yii2 and Laravel ... If you kick, poke at the right address, I will be grateful ...
P.s. I’ll ask with an addon - if you decide to make a project using frameworks ... is it necessary to customize everything for it? I just see some widgets for Yii2 .. the same calendar, etc. Or
the question, of course, rather rhetorical, but still.
Answer the question
In order to leave comments, you need to log in
Everything is simple in laravel:
There is a master template - master.blade.php
There are templates - card.blade.php, profile.blade.php
In the master template we declare a section:
@section('css')
@stop
@section('css')
@parent
<link href="..."/>
<style>
</style>
@stop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question