I am very new to magento. I am really confused how to load my own CSS files into magento. From some internet help, I came to know that, we have to save these CSS files at some location similar to
var/www/company_name/skin/frontend/default/magento_new_theme/css/folder
I also read that during installation of magento, we create all these folders or they are created automatically. (Please correct me, if wrong).
The thing is , I have no magento installed. I am accessing the magento system from website of my company. And I really want some help regarding, where, I have to go to get this var folder?
Note : It is magento but not magento go.
For using css from current theme you can use the following
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/newstyle.css') >" media="all" />
To add your own CSS files, navigate to your local xml file. It will be at app/design/frontend/package/theme/layout/local.xml
If it does not exist, make a copy from the default folder into the same location in your theme's folders. Open it up and inside the section <reference name="head"> include the below
<!-- Custom CSS -->
<action method="addItem"><type>skin_css</type><name>css/Custom_file1.css</name><params/></action>
<action method="addItem"><type>skin_css</type><name>css/Custom_file2.css</name><params/></action>
Provided these CSS files exist in your skin/frontend/package/theme/css folder then they will be added to the document's head.
use this:
<?php
$this->getSkinUrl('css/name.css');
?>
If you have using default skin package and skin template magento_new_theme then,then you can use
Mage::getSkinUrl('css/folder'); //for folder
Css file
Mage::getSkinUrl('css/folder/yourcssfile.css');
Assuming your Magento installation is at the root URI of your website, the path for CSS is "/skin/frontend/package/theme/css" and for images "/skin/frontend/package/theme/images", typically.
The 'package' and 'theme' names will be set in your Magento admin. The default package is 'base' and the theme is 'default', so that path would be "/skin/frontend/base/default/".
You will need to ask your Magento admin what the package and theme names are.
Related
I am trying to load CSS file in localhost but it's just showing white page. I was try to drag and drop file direct to browser and its opened. So file its not empty. and file also open when i use a server and add link to file.
I am using laravel 5.8, PHP 7.2
<link href="{{ URL::asset('css/style.css') }}" rel="stylesheet" type="text/css" media="all" />
CSS file location /public/css i am getting link in source http://localhost/css/style.css
This is most likely a file reference error. Check the markup output and compare the file URL against where it actually sits in the directory structure. If they match up, maybe a directory permissions issue?
In css links only asset is working fine... No need to include URL. so try using only asset.
I've just done a fresh install of the latest Symfony version. Inside my templates folder I've created a new folder called website which contains a base.html.twig and a home.html.twig.
File structure: templates/website/base.html.twig
Inside my public directory I've created the following css/app.css. Now in my base I've done:
<link rel="stylesheet" href="{{ asset('css/app.css') }}" type="text/css">
Inside my stylesheet I'm just setting the body background colour to red so I know it works. For whatever reason it isn't loading my css. When I view source it appears as:
<link rel="stylesheet" href="/css/app.css" type="text/css">
and clicking the href I just get a Symfony 404. I cannot figure out why it isn't loading my static CSS file.
I don't want to use Symfony Encore as thats overcomplicating things for my project. I have also tried assets:install command and nothing installed or changed.
UPDATE:
I installed and done a basic setup with Symfony Encore in the hope I could at least get some CSS working. Still get the exact same issue.
If you want to use the asset funtion you have to install the component first with the following command:
composer require symfony/asset
That is really all there is to it if you do not wish to use webpack encore.
Optional: If you happen to use PHPStorm with the Symfony plugin, go to settings > symfony and change Web Directory from app to public for the new directory that Symfony 4 uses. This gives you all the autocomplete goodness and your references will work.
You should store your static files inside the assets directory at the root of your project. So just place the css-folder with the app.css-file in <root>/assets/css/app.css
Source: https://symfony.com/doc/current/best_practices/web-assets.html
I created a new project using Laravel 5.5 and I am trying to link my CSS but it does not work. When I put some CSS codes nothing happens to my page. I already tried clearing my cache. I do not know whats wrong, please help. Here is how I linked my css in my app.blade.php
<link href="{{ asset('css/style.css') }}" rel="stylesheet">
Here is my css code:
body{
background-color: black;
}
Any help would be appreciated. Thanks.
If you put the css inside a css file in your resource folder, you need to build it with NPM:
npm install
then
npm run watch
If you directly put it in the public folder, have you checked to make sure you're linking the right file? Also, try ctrl + f5 to hard refresh
The file style.css must be there in the required location. By default it will be:
/public/css/style.css
Otherwise if you have changed the resource path to your web server root, then it could be:
/css/style.css
I am working with codeigniter. But CSS is not working even I use base url() function.
< link href="< ? php echo base_url(); ?>
application/views/vehicle/css/bootstrap.min.css" rel="stylesheet" media="screen" />
If I just echo base url(), it outputs
http://localhost/codeigniter/
My css is in
C:\xampp\htdocs\codeigniter\application\views\vehicle\css
Can someone please help me with this?
Your css file should be in publicly approachable directory.
Application directory (application or APPPATH) is not publicly reachable.
So your CSS file should be somewhere next to index.php file of your application.
It is common to have assets/css path started in your website root:
-application
-system
-assets
--css
---vehicle.css
-index.php
-.htaccess
And if you make your web application code that uses CSS files dinamicaly regarding of route used, you can resolve it by adding more related subfolders:
-application
-system
-assets
--css
---vehicle
----style.css
-index.php
-.htaccess
This way, after url helper is loaded, you could reach css link with:
<?php echo base_url('assets/css/vehicle/style.css');?>
Eventualy you should include assets location in .htaccess file enabling Apache server to allow reading of it.
Maybe because of the ">" closing tag before "media".
Maybe you could try with relative path. So use as many "../" as needed to go back into parent folder untill you reach root dir (if your php file is in a sub-folder) and then add the path to the CSS file.
I have a Jekyll site with some posts and some pages in the root directory.
If I navigate to a page in the root directory, such as localhost:4000/index.html all of the files in the _includes directory load no problem using:
{% include head.html %}
If I then go to a post using the permalink format as defined in config.yml:
permalink: /:categories/:title
localhost:4000/blogpost/first-post
The include files are not loaded. Looking in Firebug at the CSS files in the header it gives an error that the file is not found and is looking in the directory:
/blogpost/first-post/css/boostrap.min.css
If I give the post a permalink in YAML as:
permalink: /first-post.html
Everything works fine.
How do I set up the include to find the right files in my pages when using permalinks to navigate?
Includes and assets are two different things.
Includes are partials that are usually stored in _includes. If include anyfile.html work in index.html, it will work in any other page or post.
assets like js, css or images are loaded by html following a path. It's better to use a path relative to the site root. That's why Jekyll calls assets like this :
<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">
So, if your site is reached at http://localhost/any/path, your _config.yml look like this :
url: http://localhost
baseurl: /any/path
And then, no more problems with assets !