This question already has an answer here:
Install assets from app directory
(1 answer)
Closed 7 years ago.
Im having problems with loading my css and js files.
Css and js are in app/Resources/views/css and app/Resources/views/js folders
This is my app/Resources/views/base.html.twig
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
<link rel="stylesheet" type="text/css" href="../app/Resources/views/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../app/Resources/views/css/bootstrap-theme.min.css" />
</head>
<body>
{% block body %}{% endblock %}
<!-- this also doesnt work ofcourse -->
<script src="../app/Resources/views//js/jquery-2.1.4.min.js"></script>
<script src="../app/Resources/views//js/bootstrap.min.js"></script>
</body>
</html>
It cant find my files.
How should i solve this?
Thanks!
Your "app" folder is outside the webroot and can't be accessed. Put the files in the "web" folder instead!
Related
I created a new Laravel project and downloaded the bootstrap CSS and JS files and put the CSS file in resources/css and the JS files of bootstrap and popper and jQuery in resources/js and in the welcome.blade.php I linked the CSS file and the JS files like this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Osama The Coder</title>
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
</head>
<body>
<section class="text-danger">
Hello World
</section>
<script src="{{ asset('js/jquery-3.6.0.min.js') }}"></script>
<script src="{{ asset('js/popper.min.js') }}"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
</body>
</html>
when I opened the project it was just the text without any styles or Bootstrap font-family
even when I linked the app.css and applied color red to the section element I doesn't see any changes
Please follow the following steps
Put all your static assets in public directory
Organize your assets in different folders e.g public/js for js related files and public/css for css related files
Then access your files using the helper method like below
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
/* or js files */
<script src="{{ asset('js/jquery-3.6.0.min.js') }}"></script>
I want change in code of open cart theme but all files is .twig so when I write php code in it don't work . until when i change in the stylesheet file . the theme don't see any changes.
how I can change .twig to php and make the theme see the changes in css file ??
this is part of header.twig
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{ title }}</title>
<base href="{{ base }}" />
{% if description %}
<meta name="description" content="{{ description }}" />
{% endif %}
{% if keywords %}
<meta name="keywords" content="{{ keywords }}" />
{% endif %}
<script src="catalog/view/javascript/jquery/jquery-2.1.1.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
<script src="catalog/view/javascript/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="catalog/view/javascript/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,400i,300,700" rel="stylesheet" type="text/css" />
I want to add this code to it but when I put it in header.twig it don't work
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/style.css">
<?php if($direction=='rtl'){?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/rtl-style.css">
<?php }?>
You really shouldn't mix PHP with TWIG. Just use passed variables. Check the documentation for more info:
https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=29835
https://twig.symfony.com/doc/2.x/
Use this extension to enable twig: https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=29835
I can't figure it out what could cause this issue, but i'am pretty sure it simple. I am extending main view main.blade.php (located in views folder). This includes css from partials folder.
I have two pages: Enquire, Approved enquire. (both located in views/trader/ folder.) only difference is routing, one would have /enquires the other would have /enquires/approved.
Blade/Css working if on main route: Route::get('/enquires','Trader\PagesController#getEnquires');
Blade/Css does not work when using suburl: Route::get('/enquires/approved','Trader\PagesController#getApproved');
Please refer to this image:
routing display error
If you require any other information please let me know,
Tahnks in advance,
Dan
It seems the problem is in how you're creating links to assets (images, CSS and JS files). To make it work, use Laravel asset() helper:
<link rel="stylesheet" href="{{ asset('css/theme.css' }}">
Which will create full path to an asset.
Also, you must keep all assets inside public directory of your project, for example: /laravel_project/public/css/theme.css
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>#yield('title')</title>
<meta name="keywords" content="HTML5 Template" />
<meta name="description" content="Trusted Workers - Find local tradesmen">
<!-- Favicon -->
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" href="img/apple-touch-icon.png">
<!-- Mobile Metas -->
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Web Fonts -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800%7CShadows+Into+Light" rel="stylesheet" type="text/css">
<!-- Vendor CSS -->
<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="vendor/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="vendor/simple-line-icons/css/simple-line-icons.css">
<link rel="stylesheet" href="vendor/owl.carousel/assets/owl.carousel.min.css">
<link rel="stylesheet" href="vendor/owl.carousel/assets/owl.theme.default.min.css">
<link rel="stylesheet" href="vendor/magnific-popup/magnific-popup.css">
<!-- Theme CSS -->
<link rel="stylesheet" href="css/theme.css">
<link rel="stylesheet" href="css/theme-elements.css">
<link rel="stylesheet" href="css/theme-blog.css">
<link rel="stylesheet" href="css/theme-shop.css">
<link rel="stylesheet" href="css/theme-animate.css">
<!-- Current Page CSS -->
<link rel="stylesheet" href="vendor/rs-plugin/css/settings.css" media="screen">
<link rel="stylesheet" href="vendor/rs-plugin/css/layers.css" media="screen">
<link rel="stylesheet" href="vendor/rs-plugin/css/navigation.css" media="screen">
<link rel="stylesheet" href="vendor/circle-flip-slideshow/css/component.css" media="screen">
<!-- Skin CSS -->
<link rel="stylesheet" href="css/skins/default.css">
<!-- Theme Custom CSS -->
<link rel="stylesheet" href="css/custom.css">
<!-- Head Libs -->
<script src="vendor/modernizr/modernizr.js"></script>
I finally just got my Symfony2 app to work in Heroku except that it's not getting any CSS or JS. Does anyone know what the problem might be?
Including <head> code from the base.twig.html
<head>
<meta charset="UTF-8" />
<title>{% block title %}Machine{% endblock %}</title>
{% block stylesheets %}
<link rel="stylesheet" type="text/css" href="{{ asset('bundles/bmatznerfoundation/css/foundation.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('bundles/project/css/main.css') }}">
<link href='http://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="{{ asset('bundles/project/js/jquery-1.11.2.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/project/js/script.js') }}"></script>
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('bundles/project/favicon.ico') }}">
</head>
I noticed that it seems to be using Symfony2 favicon and such. So it might be using the wrong directory somehow, or bundle, for the "web" view of things.
it's
Root >
Web >
bundles >
bmatznerfoundation > ...
framework > (original symfony junk)
project > (THE FILES I WANT)
.htaccess
app.php
app_dev.php
apple-touch-icon.png
config.php
favicon.ico (a Symfony icon)
robots.txt
Haha, this is silly, in my .gitignore file, /web/bundles was there. I simply removed it, re-committed, then everything worked great!
laravel 4.2: my demo project in ytform when i try to add css file (style.css) from public folder having another folder, css folder. try to get any class its not working .
in View: i have an other folder, name layouts and i am accessing here css file but not working?
where in master.blade.php
<head>
#section('head')
<meta charset="UTF-8">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/css/style.css">
#show
</head>
i try with given both ways but in vain, css file not supporting in any view folder files how add css files
<link rel="stylesheet" type="text/css" href="/css/style.css">
{{HTML::style('css/style.css')}}
any solution or mistake ?
<link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}">
You can try this
or
{{ HTML::style(asset('css/site.css'), array('rel' => 'stylesheet', 'type' => 'text/css')) }}
and the css files needs to be in the public folder for this to work
Just include some lines in Blade template
{{ HTML::style('css/main.css') }}
See here as a reference