I have develop a website using CodeIgniter and Bootstrap
I have home.php and search.php
In home.php, I have a form to submit the word to be found, and post it to search.php,
and Bootstrap works fine in search.php, at this way
but I also have function in search.php which can be accessed within url
e.g. mysite.com/search/with/words/
and Bootstrap didn't works at this way
So much thank you before
As i understood your question you can use
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/bootstrap.css">
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/js/bootstrap.js">
So file structer would be
1. application
2. system
3. assets
- css
1. bootstrap.css
- js
1. bootstrap.js
4. index.php
5. .htaccess
Related
I am working on an application based on codeigniter, i have created a global layout page on that i page i have included all the css, js and other images that is in assets folder in codeigniter root.
i have included those files like below code
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/front/website/static/fonts/icomoon-greycom/css/style.css">
when i visit homepage https://mypage.com, it works fine
it loads those files as
https://mypage.com/assets/front/website/static/font/icomoon-greycom/css/style.css
but when i visit other links like.
https://mypage.com/region/india
den it load
https://mypage.com/region/india/assets/front/wesbite/static/font/icon-greycom/css/style.css
but i want it should load only https://mypage.com/assets/assets/front/wesbite/static/font/icon-greycom/css/style.css
in my config.php page
$config['base_url'] = "https://www.mypage.com/";
how to solve this issue.
Put the asset path inside the base_url function (as per the docs).
e.g.
<?php echo base_url('assets/front/website/static/fonts/icomoon-greycom/css/style.css'); ?>
Use this:
<link rel="stylesheet" href="<?php echo site_url(); ?>assets/front/website/static/fonts/icomoon-greycom/css/style.css">
Can Use
href="<?php echo base_url().'assets/front/website/static/fonts/icomoon-greycom/css/style.css'; ?>"
i have problem on load asset css(bootstrap and image) on pagination php
my main / default page is
and of course the image and css is loaded
http://localhost:8080/iklan/
....
but when i entered page 2 into..
http://localhost:8080/iklan/iklan/index/2
the image and the css bootstrap wont show
...
maybe it because the function index controller $config["base_url"] = base_url().'/iklan/index';
my css is on asset
C:\xampp\htdocs\iklan\aset
while my image is on
C:\xampp\htdocs\iklan\upload_iklan
and i call css on view like this
<link rel="stylesheet" href="aset/bower_components/bootstrap/dist/css/bootstrap.min.css">
anyone know how to load the css?
Change your base url from
$config["base_url"] = base_url().'/iklan/index';
to
$config['base_url'] = site_url('/iklan/index');
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>aset/bower_components/bootstrap/dist/css/bootstrap.min.css" />
Hope this will help you :
First set ur base url in config.php
$config['base_url']= 'http://localhost/iklan/';
and load css and js by using site_url();
site_url() returns your site URL, as specified in your config file. The index.php file will be added to the URL automatically
<link rel="stylesheet" href="<?=site_url('aset/bower_components/bootstrap/dist/css/bootstrap.min.css');?>" >
Note : make sure your css file path is correct
For more : https://www.codeigniter.com/user_guide/helpers/url_helper.html
IM trying to load some css directly within my view file, but its not working.
in my view file I have this.
<link href="<?php echo base_url(); ?>assets/css/core.css" rel="stylesheet" type="text/css" />
The assets folder is at the same level as Application
when I view source on the webpage it shows me this
demo.example.com/assets/css/core.css
but when i click the link to see if it's working the url becomes this...
http://demo.example.com/admin/demo.example.com/assets/css/core.css
not sure what I am doing wrong? Should I be adding something to my htaccess file?
Thanks in advance.
You don't need to include the base_url() in your path because the webserver already knows your at www.example.com/admin and auto includes that.
Just use
<link href="/assets/css/core.css" rel="stylesheet" type="text/css" />
Edit: Or actually you need to include the http: prefix on your base_url like wolfgang1983 said.
See this answer on CSS absolute and relative link paths. https://stackoverflow.com/a/17621358/3585500
I have the following route which loads the page but the css of the page doesn't loads.
Route::get('admins', function () {
return view('admins/index');
});
In the contrast the following route loads the same page but here I added index and the page loads correctly. but I also adds index with admins in the browser address bar.
Route::get('admins/index', function () {
return view('admins/index');
});
I am calling css files in the views like:
<link href="../assets/css/animate.min.css" rel="stylesheet" />
I searched for the solutions but didn't got anything.
For Laravel 4 & 5:
<link rel="stylesheet" href="{{ URL::asset('assets/css/animate.min.css') }}">
URL::asset will link to your project/public/ folder, so chuck your scripts in there.
Note: You'll need to be using blade templates to use this. All Blade templates should use the .blade.php extension.
i am using code like below for css and js :
<link rel="stylesheet" href="{{ asset('/') }}css/menu-style.css">
And css directory is in my "project/public" directory.
I am currently testing my website on the local server. I have issues with twitter bootstrap's path in my header view.
On my homepage this path works fine:
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
When I move to sub-page via link:
<a href="index.php/home_controller/getFilmDetails?id...
Which translates to:
http://localhost/www.mywebsite.co.uk/index.php/home_controller/getFilmDetails?id=114
Controller code:
$this->load->view('/header/header_home');
$this->load->view('movies_details_view',$data);
$this->load->view('footer_home');
Path to twitter bootstrap does not work, and I need to change the path to:
<link href="/bootstrap/css/bootstrap.css" rel="stylesheet">
How do I make the path work on all pages?
In your Controller do this:
$this->load->helper('url');
$this->load->view('/header/header_home');
$this->load->view('movies_details_view',$data);
$this->load->view('footer_home');
Inside you header view do this:
<link href="<?php echo base_url('/bootstrap/css/bootstrap.css') ?>" rel="stylesheet">