Welcome Guest, Not a member yet? Register   Sign In
$this->load->file that i want??[SOLVED]
#1

[eluser]Ngulo[/eluser]
ahahah sorry man ,maybe i will result really banal

i'm wonder is possible to have something like this in Codeigniter?

Code:
$this->load->my_folder('my_file');

thanks Wink
#2

[eluser]Starovich[/eluser]
[quote author="ispuk" date="1270182676"]ahahah sorry man ,maybe i will result really banal

i'm wonder is possible to have something like this in Codeigniter?

Code:
$this->load->my_folder('my_file');

thanks Wink[/quote]

Well, not exactly like that, but you could write a library that gets the content of a file and then call

Code:
$data['my_file'] = $this->my_file_getter_library->load_file("/folder/filename.txt");
#3

[eluser]flaky[/eluser]
you can load a file with codeigniter
Code:
$this->load->file('filepath/filename', true/false);

read the user guide
#4

[eluser]Ngulo[/eluser]
thank you guys, your solutions are pretty amazing!!!!

flaky's solution seems to be all that i was looking for

flaky do you know,must i specify the file extension ?

can i do this for example:
Code:
$this->load->file('css/style.css',true/false)

instead of:
Code:
<link type="text/css" rel="stylesheet" href="css/style.css" media="screen" />

it's the same way of including css stylesheets?

thanks again!!! Wink
#5

[eluser]flaky[/eluser]
if you want to store the text/data from the file to a variable do this
Code:
$this->load->file('css/style.css',true);
if you want it to be output like a view then instead of true use false

$this->load->file() is only for getting the contents of a file not for creating html content

cheers
#6

[eluser]Ngulo[/eluser]
really thanks Wink
#7

[eluser]Starovich[/eluser]
[quote author="flaky" date="1270208844"]you can load a file with codeigniter
Code:
$this->load->file('filepath/filename', true/false);

read the user guide[/quote]

That's really handy, thanks for the tip!
#8

[eluser]Ngulo[/eluser]
guys only another one question

if i load the file without using any of True/False ,are there any problems?

it seems to work also without True/False statment ....but i'm wondering why,just for understanding Wink

thanks again
#9

[eluser]PĂ©turV[/eluser]
[quote author="ispuk" date="1270256168"]guys only another one question

if i load the file without using any of True/False ,are there any problems?

it seems to work also without True/False statment ....but i'm wondering why,just for understanding Wink

thanks again[/quote]

http://ellislab.com/codeigniter/user-gui...oader.html

This is a generic file loading function. Supply the filepath and name in the first parameter and it will open and read the file. By default the data is sent to your browser, just like a View file, but if you set the second parameter to true (boolean) it will instead return the data as a string.
#10

[eluser]Ngulo[/eluser]
thanks but i do not understand at all....if i don't specify any False or True parameter ,it will be included only?

this:

$this->load->file('path_to_file');

is the same as:
include('path_to_file');

??

thanks again Wink




Theme © iAndrew 2016 - Forum software by © MyBB