view included in all files having bootstrap files path not working in diffrent route - laravel

Route::get('fullDetail/{productId}','productController#showSingleProduct');
http://localhost/laravel-ecommerce1/fullDetail/233
file containing bootstrap files path change from
http://localhost/laravel-ecommerce1/bootstrap.min.css
to
http://localhost/laravel-ecommerce1/fullDetail/bootstrap.min.css

Add this in your blade template
<base href="/laravel-ecommerce1">
<link rel="stylesheet" href="/bootstrap.min.css">
the assets are linked relatively and the / means link from the root

Related

Why my css file is not loading in laravel?

I am very new to the laravel , i have done login blade file and i included css files but it's not loading css files ,can you please help me where did i mistake ..?
users.blade.php
<link rel="stylesheet" href="{{ asset('resources/css/user.css') }}">
You're trying to access the resources folder, which is not exposed to the public, you'll have to compile your css so it lives in the public folder, which is the folder that anyone(including your frontend) can access using https://your-url.tld/{public file path}. There are 2 ways in which you can have your user.css file available for to your frontend:
One:
You can import your user.css file to the existing resources/css/app.css file:
/* app.css file */
#import "../path/to/user.css";
Two:
You can compile user.css to a separate file, in case you want to use that file specifically on another layout or blade file instead of mixing it globally with the app.css file:
// webpack.mix.js file
mix.js('...')
.css('resources/css/user.css', 'public/css');
Then in your layout file:
// app.blade.php file
<link rel="stylesheet" href="{{ asset('css/user.css') }}">
Hope it helps.

My css files are not running inside my .blade.php file

I'm doing a little website for me with Laravel 8.0.
Inside home.blade.php, I have this : <link rel="stylesheet" href="{{ asset('css/header.css') }}">
But when I go to my browser, no css in my page. Inside the developper tools, it says <link rel="stylesheet" href="http://localhost/css/header_site.css">.
I have all my css inside the public/assets/css folder.
I also used the VirtualHost inside httpd-vhosts.conf where I do DocumentRoot "C:/xampp/htdocs/my-project/public".
Cordially
Try configuring the assets url in the .env file. ASSET_URL=http://localhost/assets/. Then do {{asset('css/header.css')}}

How I can call a file in CodeIgniter, that has existed in core folder

I am a absolute beginner of CodeIgniter, Now I was creating a simple project with CI. But I don't know how I can call a file that has existed in core folder.
Core folder is like the following
/core/bootstrap/bootstrap.css
I want to call bootstap.css from my view/admin/index.php
How I can call it?
I already try it like the following
<link href="/application/core/bootstrap/bootstrap.css" rel="stylesheet" media="screen">
but it still doesn't work.
You should not put your CSS files in the core folder. Best practice with CI is the following:
- application
- assets
-- css
-- js
-- images
- system
-- <all CI folders here>
Use a URL helper to point to the assets folder like:
function asset_url(){
return base_url().'public/';
}
more info on url_helpers
Then you can point to your assets in your view like this:
<link rel="stylesheet" href='<?php echo asset_url()."css/YOUR_FILE.css" ?>'/>
Look at documentation and read about url_helper.
Use internal links with function site_url() or base_url()
First of all I will not put my css files in the core folder.
I will create folder which is in the same level as in the "application" and "system" folder.
Secondly, you need to configure the base url at application/confi/config.php like
$config['base_url'] = 'http://localhost/NV/';
With in the folder "NV", I have my CI files such as "application" and "system".
Then in the view I will just use
<link rel="stylesheet" href="<?php echo base_url();?>css/ace.min.css"/>
In this case, the "CSS" folder resides as in the same level as "application" and "system" folders.

.htaccess redirect for subfolder images and stylesheets

Is it possible with a .htaccess redirect to have all style sheets and image paths, that are located in a subfolder, point to the appropriate folder(images/styles) in the the root folder? With out having to change the path in each file.
Let me try to explain my situation a little better.
Im using an include (header.inc.php) that contains my doctype, stylesheet links
<link href="styles/layout.css" rel="stylesheet" type="text/css">
and a couple other html element/images.
That becomes an issue when header.inc.php in pulled into my subfolder files, because style/layout.css does not exist in that folder. Additionally there are
a couple images that break because of the same reason,
<img src="images/image.jpg">
the images folder does not exist…
In my current .htaccess file, I have the below script with my include path (for local testing). Is there something similar to the include_path script that can help with the issues listed above?
php_value include_path ".:/Applications/MAMP/bin/php/php5.4.4/lib/php:/Applications/MAMP/htdocs/site/inc"
Here is an example of the file structure/hierarchy.
[ROOT FOLDER]
index.php
/subfolder
subpage1.php
subpage2.php
subpage3.php
/subfolder2
subpage1.php
subpage2.php
subpage3.php
contact.php
/images
/styles
/scripts
/inc
You don't need to use rewrites to solve this you just need to now how to define the source properly in your HTML elements.
Don't do this
<link href="styles/layout.css" rel="stylesheet" type="text/css">
Do this
<link href="/styles/layout.css" rel="stylesheet" type="text/css">
What this has changed is that your path is no longer relative to the file being browsed to but is now relative to the root of your web site.
Hope that helps.

htaccess redirect localhost

I have
<link href="/smarter-computing/us/en/sc-mobile.css" type="text/css"/>
<script src="/smarter-computing/js/sc-common.js?fileversion-r21" type="text/javascript">//</script>
When I am working on these files locally I have to keep append //localhost/~vc/ before the path for JS and CSS files. I don't want to keep copy/pasting this path for the following and every <img> links in my code.
How can I use htaccess to redirect all url's pointing to //localhost/smarter-computing/ or /smarter-computing/ to append this path //localhost/~vc/ before my /smarter-computing path.
Thank you,
Vishwas
You can either make the document root your home directory in your apache config in localhost, or add this to the header of your pages:
<base href="/~vc/">

Resources