Cannnot access public folder in laravel8 - css

In laravel app, I have kept my css and js is asset folder inside public folder and I call these css my blade using
<link rel="stylesheet" href="{!! asset('assets/front-end/assets/css/owl.theme.default.min.css') !!}">
but when Execute page in browser , this css file is not executing so I tried to access this url directly through browser url 'http://127.0.0.1:8000/assets/front-end/assets/css/owl.theme.default.min.css'
then the result shows like 'This page is not working'.
my pblic folder css accessing tree is
public/assets/front-end/assets/css
Please advise

change it:
href="{!! asset('assets/front-end/assets/css/owl.theme.default.min.css') !!}"
to:
href="{{ asset('assets/front-end/assets/css/owl.theme.default.min.css') }}"
{!! !!} is for rendering tags in text

Firstly you check your public folder, css file location.
Change it -
<link rel="stylesheet" href="{!! asset('assets/front-end/assets/css/owl.theme.default.min.css') !!}">
Right - <link rel="stylesheet" href="{{ asset('assets/front-end/assets/css/owl.theme.default.min.css') }}">
or
<link rel="stylesheet" href="{{ asset('/') }}assets/front-end/assets/css/owl.theme.default.min.css">
I hope this is help for you!

to access a resource in Laravel you need to use the {{ }} syntax and call the URL::asset() method:
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/assets/front-end/assets/css/owl.theme.default.min.css') }}">
more details about accessing resources in laravel: how to access file in public folder

Related

How to get the CSS rules that a Django Template would use?

Let's just say I have a basic class-based view like:
from django.views.generic import TemplateView
class HomePage(TemplateView):
template_name = "homepage.html"
and in homepage.html of course we load some CSS, apocryphally:
{% extends "base.html" %}
{% load static %}
{% block CSS %}
<link rel="stylesheet" type="text/css" href="{% static 'css/default.css' %}" />
<link rel="stylesheet" type="text/css" href="some CDN based CSS file' %}" />
{% endblock %}
Now I'd like the view to read/load the CSS that will be sent to the client.
If we could just find the source files, we could parse them with cssutils.
And of course it's technically possible to find and parse the template file too, but Django already implements that and has a template loader. Is there any way short of rendering the template into a string, and trying to parse the HTML to extract CSS rules? And even if that's the path we need to pursue, is there a package that will given rendered HTML, and return the CSS rules?
An interesting problem that arises from the need, server-side, to extract some CSS information, notably colours.

Twig js, if url contains ‘batch’

I’m new to a project using Twig js. I’ve been playing around with a template trying to get it to work but with no luck.
Is there anyway of writing.
If url contains ‘batch-‘ then load these 2 CSS files, else load this 1 CSS file?
Any help is greatly appreciated,
Thanks in advance
In order to do that you'll have to pass the url that you want to check to the template and then you'll be able to add the following:
{% if 'batch-' in url %}
<link rel="stylesheet" href="style1.css">
<link rel="stylesheet" href="style2.css">
{% else %}
<link rel="stylesheet" href="style1.css">
{% endif %}

How to create web page profile

i'm new in symfony and i want to create a user profile like this exemple profile
<link href="{{ asset('bootstrap/dist/css/bootstrap.min.css') }}" rel="stylesheet">
<link href="{{ asset('bower_components/bootstrap-extension/css/bootstrap-extension.css') }}" rel="stylesheet">
<link href="{{ asset('css/animate.css') }}" rel="stylesheet"
Please excuse my english .
I think all that you need is to extend the FosUserBundle
If you have already configured you must have at least the User Entity extended.
You can create there the new fields and add this new fields to entity, form, views
You can find more documentation in the FosUser
https://symfony.com/doc/current/bundles/FOSUserBundle/overriding_controllers.html
https://symfony.com/doc/master/bundles/FOSUserBundle/overriding_forms.html
https://symfony.com/doc/master/bundles/FOSUserBundle/overriding_templates.html
Other Tip: You can copy past any controller from vendors friensdofsymfony in your extended and change their behavior

Why doesn't my jekyll github site have styles?

This is my repository: https://github.com/attilay/jeky
How my website should look like and the repository of theme: http://themes.jekyllrc.org/linear/
My website doesn't load any styling, just plain HTML. Why?
First, in _layouts/default.html, include {{ site.baseurl }} in the relative paths to assets in your head (as David Jacquel suggests):
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/skel-noscript.css" />
and
<script src="{{ site.baseurl }}/assets/js/init.js"></script>
In addition, in /assets/js/init.js change:
prefix: '/assets/css/style',
to
prefix: '{{site.baseurl}}/assets/css/style',
and, finally, in order for Jekyll to process init.js and insert the baseurl, add
---
---
at the top of the file as empty YML frontmatter.
In your _layouts/default.html, You must call your assets with :
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/skel-noscript.css" />
or
<script src="{{ site.baseurl }}/assets/js/init.js"></script>

Included css from controller doesn't apply on page

I'm actually trying to set in my twig template css generated from a controller. File is included (if I access the url of the controller in my browser I see generated css) but not applied.
For more details, I've got a twig template (base.html.twig) in which I include controller result using <link rel="stylesheet" type="text/css" href="{{ path('mycsscontroller') }}">.
The 'mycsscontroller' route go to MyCssController:indexActionwhich return $this->render('mytwigfile.css.twig').
The content generated is a valid css.
I already tried to set generated content in a file then include it using <link rel="stylesheet" type="text/css" href="{{ asset('mycssfile') }}"> and css is included and applied on page!
I really don't understand what I'm doing wrong there...
Thanks
Try return response in you controller with css content type
return new Response('my_css_styles_as_string', 200, ['Content-Type'
=> 'text/css'])

Resources