php-mvc-framework
php-mvc-framework copied to clipboard
How to render js files in views
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
That is not straight forward and directly possible at the moment. One Simple solution will be
- to extend Application class
- Use the new Application class into
public/index.php - Add
$jsand$cssarrays into extended class - From controllers's method put your JavaScript or CSS files into new Application class
$jsand$css - Iterate over them into
layout/main.phpand render them.
@mahmoudIsProgramer Let me know if this helps.