Good morning to you all,
I'd like to ask you for help because I don't understand where my problem with adding a favicon with Symfony 6 comes from.
I have two codes in mind, this one
<link rel="icon"
href="{{ '/images/' ~ 'favicon.jpg' }}"
type="image/x-icon"
src="" />
as well as this one
<link rel="icon"
href="{{ asset('/images/' ~ 'favicon.jpg') }}"
type="image/x-icon"
src="" />
None of the codes work.
I even get this error in Symfony when I put assets in my code, and I use yarn.
An exception has been thrown during the rendering of a template ("Asset manifest file "C:\wamp64\www\projet-conrad-angela/public/build/manifest.json" does not exist. Did you forget to build the assets with npm or yarn?").
<link rel="icon"
href="{{ asset('/images/' ~ 'favicon.jpg') }}"
type="image/x-icon"
src="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{# Run `composer require symfony/webpack-encore-bundle` to start using Symfony UX #}
If you have a solution, I would be delighted to help. Thank you.
You can do this:
<link rel="icon" type="image/jpg" href="{{ asset('favicon.jpg') }}" />
https://symfony.com/doc/current/reference/twig_reference.html#absolute-url
or
<link rel="icon" type="image/jpg" href="{{ absolute_url('favicon.jpg') }}" />
https://symfony.com/doc/current/reference/twig_reference.html#reference-twig-function-asset
and you can combine both:
<link rel="icon" type="image/jpg" href="{{ absolute_url(asset('favicon.jpg')) }}" />
Related
I am using latest bits of Blazor WebAssembly Hosted Project.
I found a strange behaviour in that when i pass a non-exisitng route to api, the return status is 200 success becuase it return default html blazore page(index.html).
HttpResponseMessage response = await _Http.GetAsync($"api/Account/OTPVerification?userName={loggidInUser.Email}&OTP={_OTP}");
if (response.IsSuccessStatusCode)
{
}
The actual response returned is, which turns out to be(index.html) 200, success, whereas it is no where what i expect
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>BlazorWebAssembly</title>
<base href="/" />
<script src="https://kit.fontawesome.com/xxxxxxxxxxf.js" crossorigin="anonymous"></script>
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/app.css" rel="stylesheet" />
<link href="manifest.json" rel="manifest" />
<link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
<link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet" />
<link href="_content/Blazored.Toast/blazored-toast.min.css" rel="stylesheet" />
</head>
<body>
<app>Loading...</app>
<div id="blazor-error-ui">
An unhandled error has occurred.
Reload
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script>navigator.serviceWorker.register('service-worker.js');</script>
</body>
</html>
In your Startup.cs you can try removing:
endpoints.MapFallbackToFile("index.html");
So in your ApiController, if it's not in the route, it will return a 404 instead of index.
I have an ASP.NET MVC application that uses the Metronic template from keenthemes.
When i use bundles in my layout for my css , it doesnt work well. Most of the icons do not appear
If i switch to direct links then everything is ok.
Javascript is ok.
Bundles config and layout use:
bundles.Add(new StyleBundle("~/bundles/metronic-app").Include(
"~/assets/global/plugins/font-awesome/css/font-awesome.min.css",
"~/assets/global/plugins/simple-line-icons/simple-line-icons.min.css",
"~/assets/global/plugins/uniform/css/uniform.default.css",
"~/assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css",
"~/assets/global/css/components.css",
"~/assets/global/css/plugins.css",
"~/assets/admin/layout2/css/layout.css",
"~/assets/admin/layout2/css/themes/default.css",
"~/assets/admin/layout2/css/custom.css"));
#Styles.Render("~/bundles/metronic-app")
Direct links:
<link href="~/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="~/assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css">
<link href="~/assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css">
<link href="~/assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN THEME STYLES -->
<link href="~/assets/global/css/components.css" rel="stylesheet" type="text/css" />
<link href="~/assets/global/css/plugins.css" rel="stylesheet" type="text/css" />
<link href="~/assets/admin/layout2/css/layout.css" rel="stylesheet" type="text/css" />
<link id="style_color" href="~/assets/admin/layout2/css/themes/default.css" rel="stylesheet" type="text/css" />
<link href="~/assets/admin/layout2/css/custom.css" rel="stylesheet" type="text/css" />
Here are the errors from chrome console:
I should have been using the CssrewriteUrlTransform class in my bundle configuration in order to make the asset's paths absolute.
What worked is this:
bundles.Add(new StyleBundle("~/bundles/metronic-app").Include(
"~/assets/global/plugins/uniform/css/uniform.default.css",
"~/assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css",
"~/assets/global/css/components.css",
"~/assets/global/css/plugins.css",
"~/assets/admin/layout2/css/custom.css")
.Include("~/assets/admin/layout2/css/layout.css", new CssRewriteUrlTransform())
.Include("~/assets/admin/layout2/css/themes/default.css", new CssRewriteUrlTransform())
.Include("~/assets/global/plugins/font-awesome/css/font-awesome.min.css", new CssRewriteUrlTransform())
.Include("~/assets/global/plugins/simple-line-icons/simple-line-icons.min.css",new CssRewriteUrlTransform()));
Hint from this SO Question
I am almost done with my theme system for my codeigniter.
Come across a issue with style sheets have error 403 local host.
It was working on my other one but my new version will not pick up
Each theme has its on style sheet folder and java script. Most people say its wrong to do it that way but. This way is much more better for theme system.
theme/default
theme/default/stylesheets/stylesheet.css
theme/default/javascript/common.js
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="" />
<meta name="keywords" content="" />
<title><?php echo $this->config->item('title'); ?></title>
<base href="<?php echo base_url(); ?>">
<link rel="stylesheet" type="text/css" href="application/views/theme/default/stylesheets/stylesheet.css" media="screen">
</head>
theme/codeigniter
theme/codeigniter/stylesheets/stylesheet.css
theme/codeigniter/javascript/common.js
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="" />
<meta name="keywords" content="" />
<title><?php echo $this->config->item('title'); ?></title>
<base href="<?php echo base_url(); ?>" >
<link rel="stylesheet" type="text/css" href="application/views/theme/codeigniter/stylesheets/stylesheet.css" media="screen" >
</head>
I think direct access inside the applications folder will be revoked by the Code Ignitor. Hence, i put all put all images,CSS and JS in a folder named assets in the CI ROOT FOLDER, along with applications, system & user_guide.
Now, Make a file named utility_helper.php in ROOT_FOLDER/application/helper and add the following code
<?php
function asset_url(){
return base_url().'assets/';
}
?>
then add utility to application/config/autoload.php at line 67
$autoload['helper'] = array('utility');
Now when ever you want to access the asset folder, you can call it as
<link rel="stylesheet" type="text/css" href="<?php echo asset_url();?>stylesheets/stylesheet.css" />
<link rel="stylesheet" type="text/css" media="all" href=<?php echo
base_url()."application/views/theme/codeigniter/stylesheets/stylesheet.css"?> />
I've created a new environment called 'staging' which is pretty much the same config as the 'production' environment and I'm trying to use yui_compressor on my css and js files. Please see an example of my css files below:
{% stylesheets output='css/compiled/main.css' filter='?yui_css' filter='cssrewrite'
'bundles/xyz/lib/frontend/css/social_foundicons.css'
'bundles/xyz/lib/frontend/css/general_enclosed_foundicons.css'
'bundles/xyz/lib/frontend/css/general_foundicons.css'
'bundles/xyz/lib/frontend/coda/css/coda-slider.css'
%}
<link rel="stylesheet" type="text/css" media="screen" href="{{ asset_url }}" />
{% endstylesheets %}
<!-- Google fonts -->
{% stylesheets output='css/compiled/fonts.css' filter='?yui_css' filter='cssrewrite'
'bundles/xyz/lib/frontend/css/fonts.css'
%}
<link rel="stylesheet" type="text/css" media="screen" href="{{ asset_url }}" />
{% endstylesheets %}
<!-- Included CSS Files -->
{% stylesheets output='css/compiled/style.css' filter='?yui_css' filter='cssrewrite'
'bundles/xyz/lib/frontend/css/style.css'
%}
<link rel="stylesheet" type="text/css" media="screen" href="{{ asset_url }}" />
{% endstylesheets %}
When deploying using capistrano the following files are created:
/web/css/compiled/fonts.css
/web/css/compiled/main.css
/web/css/compiled/style.css
This I assume is correct, however the header in my application renders the following:
<link rel="stylesheet" type="text/css" media="screen" href="/css/compiled/main_social_foundicons_1.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/css/compiled/main_general_enclosed_foundicons_2.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/css/compiled/main_general_foundicons_3.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/css/compiled/main_coda-slider_4.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/css/compiled/fonts_fonts_1.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/css/compiled/style_style_1.css" />
None of the above files exist on the server and I assume it should be calling /css/compiled/fonts.css, main.css and style.css.
Anyone know why it's doing this?
Thanks
The problem was that I had debug mode set to true for the staging environment.
I have a wordpress site I am using ie conditional comments to load in an ie specific stylesheet in to. For some reason the changes made aren't being reflected in IE's rendering:
I have tried:
clearing browser history
deleting and re-uploading the file
ensuring the conditional comment is correct
closing all browsers and restarting
checking the file path
Adding php style now() to force refresh
And I've reached a point where I'm baffled.
What else can I try?
edit:
the code:
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>K9 Heaven - 21st Century Dog Care</title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="http://www.k9heaven.org.uk/wp-content/themes/k9_0.2/style.css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" media="all" href="ie.css" />
<![endif]-->
<link rel="pingback" href="http://www.k9heaven.org.uk/xmlrpc.php" />
<!--[if lt IE 9]>
<script src="http://www.k9heaven.org.uk/wp-content/themes/k9_0.2/js/html5.js" type="text/javascript"></script>
<![endif]-->
<link rel="alternate" type="application/rss+xml" title="K9 Heaven » Feed" href="http://www.k9heaven.org.uk/?feed=rss2" />
<link rel="alternate" type="application/rss+xml" title="K9 Heaven » Comments Feed" href="http://www.k9heaven.org.uk/?feed=comments-rss2" />
<link rel="alternate" type="application/rss+xml" title="K9 Heaven » Home Comments Feed" href="http://www.k9heaven.org.uk/?feed=rss2&page_id=49" />
<link rel='stylesheet' id='NextGEN-css' href='http://www.k9heaven.org.uk/wp-content/plugins/nextgen-gallery/css/nggallery.css?ver=1.0.0' type='text/css' media='screen' />
<link rel='stylesheet' id='shutter-css' href='http://www.k9heaven.org.uk/wp-content/plugins/nextgen-gallery/shutter/shutter-reloaded.css?ver=1.3.2' type='text/css' media='screen' />
<script type='text/javascript' src='http://www.k9heaven.org.uk/wp-includes/js/l10n.js?ver=20101110'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var shutterSettings = {
msgLoading: "L O A D I N G",
msgClose: "Click to Close",
imageCount: "1"
};
/* ]]> */
</script>
<script type='text/javascript' src='http://www.k9heaven.org.uk/wp-content/plugins/nextgen-gallery/shutter/shutter-reloaded.js?ver=1.3.2'></script>
<script type='text/javascript' src='http://www.k9heaven.org.uk/wp-includes/js/jquery/jquery.js?ver=1.6.1'></script>
<script type='text/javascript' src='http://www.k9heaven.org.uk/wp-content/plugins/nextgen-gallery/js/jquery.cycle.all.min.js?ver=2.88'></script>
<script type='text/javascript' src='http://www.k9heaven.org.uk/wp-content/plugins/nextgen-gallery/js/ngg.slideshow.min.js?ver=1.05'></script>
<script type='text/javascript' src='http://www.k9heaven.org.uk/wp-includes/js/comment-reply.js?ver=20090102'></script>
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.k9heaven.org.uk/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://www.k9heaven.org.uk/wp-includes/wlwmanifest.xml" />
<link rel='index' title='K9 Heaven' href='http://www.k9heaven.org.uk' />
<link rel='prev' title='Contact' href='http://www.k9heaven.org.uk/?page_id=25' />
<meta name="generator" content="WordPress 3.2.1" />
<!-- All in One SEO Pack 1.6.13.3 by Michael Torbert of Semper Fi Web Design[395,435] -->
<meta name="description" content="K9 Heaven - 21st Century Dog Care" />
<meta name="keywords" content="K9,Heaven,21st,Century,Dog,Care" />
<link rel="canonical" href="http://www.k9heaven.org.uk/" />
<!-- /all in one seo pack -->
<meta name='NextGEN' content='1.8.3' />
<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
</head>
http://www.k9heaven.org.uk/
Feel free to close this thread, forgot that relative css paths in wordpress themes go to the site root, not the theme root. And won the stupid hat.
Is this
http://www.k9heaven.org.uk/ie.css
the sheet you're tyring to load? or is it this:
http://www.k9heaven.org.uk/wp-content/themes/k9_0.2/ie.css
The code above is referencing the first style sheet at the root of the site. That's non-standard. You should use <?php get_theme_root() ?> in the style sheet link in the theme files to target the style sheet in the theme folder.