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

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.

Related

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

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

Codeigniter: include js files ci folder is installed outside http folder

I am new in CI - and the framework is awesome.
These are the best answers I can get:
- CodeIgniter: How do I include a .js file in view?
- Codeigniter: How to include javascript files
I am trying to include js/css files but:
My CI folder including application and system are not installed on the http(/var/www/)[for default installation] folder, I placed somewhere else. So i assume their installations above are in http default folder, I have :
http:/var/www
CI:
/opt/codeigniter
+aplication
+system
Thank you so much in advance
Use this code
<script href="<?php base_url().'path/to/file' ?>" type="text/javascript"></script>
The javascript folder should be outside the application folder
app_folder
-application
--views
--controllers
-system
-css
-js
Hope this helps

Access to root folder from subdomains (Codeigniter)

I have some trouble to access root dir files when using subdomains:
My css files located in css dir in the root.
If i use url "my-site.com/css/file.css" - everything okay
If i use url "en.my-site.com/css/file.css" - 404 error
How can i fix it? I don't want to hardcode path to all my css and js files.
Thanks
try this for for loading all images, styles, js
<link rel="stylesheet" href="<?php echo site_url('css/file.css'); ?>">
don't forgot to create directory in your main CI folder.
if you not able to get that like this:
<link rel="stylesheet" href="<?php echo base_url(); ?>css/file.css">
you have a server problems and it is not Codeigniter related ;)

.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.

LInking to CSS from Module CodeIgniter

So I have a module setup and working, and have setup an asset folder within it containing a css and js folder. My files are in there, but when I try linking to them like this:
<script type="text/javascript" src=/application/modules/badge_progress/assets/js/jquery.jcarousel.js"></script>
Or this:
<script type="text/javascript" src=<?php echo base_url(); ?>/application/modules/badge_progress/assets/js/jquery.jcarousel.js"></script>
They don't work. What is the proper way to link to the files?
You have a problem with your quotation marks. The src value starts with no quotation mark but ends with one. Try
<script type="text/javascript" src="<?php echo base_url();?>/application/modules/badge_progress/assets/js/jquery.jcarousel.js"></script>`
You cant access directly from /application folder from web browser.
Move badge_progress folder with same directory with application and try this
<script type="text/javascript" src="<? echo base_url();?>badge_progress/assets/js/jquery.jcarousel.js"></script>
keep your js and css file in root folder and try and check in firebug js file and css file is loading or not and what path is created for that file and then fix it.

Resources