Hello!
I have some doubts about the best way to make links to JavaScript libraries and CSS files. I have a template (base.volt):
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{% block title %}{{ title }}{% endblock %}</title>
<meta content="es" name="language">
<link rel="stylesheet" href="{{ static_url('assets/bootstrap/css/bootstrap.min.css') }}">
<script src="{{ static_url('assets/fontawesome/svg-with-js/js/fontawesome-all.min.js') }}"></script>
<link rel="stylesheet" href="{{ static_url('css/base.css') }}">
{% block extracss %}{% endblock %}
<link rel="shortcut icon" type="image/x-icon" href="{{ static_url('img/favicon.ico') }}"/>
</head>
<body>
{% include 'templates/navbar.volt' %}
{% include 'templates/footer.volt' %}
<main role="main" class="container">
<div class="starter-template">
{% block content %}{% endblock %}
</div>
</main>
<script src="{{ static_url('assets/jquery/jquery.min.js') }}"></script>
<script src="{{ static_url('assets/popper/popper.min.js') }}"></script>
<script src="{{ static_url('assets/bootstrap/js/bootstrap.min.js') }}"></script>
<script src="{{ static_url('js/base.js') }}"></script>
<script>
var base_uri = '{{ config.application.baseUri }}';
var rewrite_uri = '{{ router.getRewriteUri() }}';
var url = (base_uri+rewrite_uri).replace("//","/");
</script>
{% block extrajs %}{% endblock %}
</body>
</html>
Doing this way I can use extra CSS and JS files in another volt file that extends from base.volt in this way:
{% block extrajs %}
<script src="{{ static_url('assets/bootbox/bootbox.min.js') }}"></script>
></script>
{% endblock %}
{% block extracss %}
<link rel="stylesheet" href="{{ static_url('css/forms-styles.css') }}">
{% endblock %}
I think it's a mistake to use static_url
method. Which is the best way? I want to optimize to the maximum possible with Phalcon.
By the way, is this the best way to link an image? <img class="img-fluid" src='{{ static_url('img/logo.png') }}'>
Thanks for your patience (I'm new at MVC) :-)
All the best.