php-mvc-framework icon indicating copy to clipboard operation
php-mvc-framework copied to clipboard

How to render js files in views

Open mahmoudahmed2222 opened this issue 3 years ago • 1 comments

Hello thecodeholic , thanks a lot for the the great course and the lovely educational materials . in layouts/main.php there exist {{content}} and as i understood it's to replace the content of view , how can i make similar to this but for js files , i want to load js file in my view without putting it in layouts/main.php beofr

tag

mahmoudahmed2222 avatar Aug 27 '22 21:08 mahmoudahmed2222

That is not straight forward and directly possible at the moment. One Simple solution will be

  1. to extend Application class
  2. Use the new Application class into public/index.php
  3. Add $js and $css arrays into extended class
  4. From controllers's method put your JavaScript or CSS files into new Application class $js and $css
  5. Iterate over them into layout/main.php and render them.

@mahmoudIsProgramer Let me know if this helps.

thecodeholic avatar Sep 25 '22 11:09 thecodeholic