Welcome Guest, Not a member yet? Register   Sign In
including image in a page.
#1

[eluser]Unknown[/eluser]
hi

i have root folder and in the folder i have placed a image folder , CSS folder and a view.php file,i have included images and CSS from the proper folder and included in my view.php file . its works fine when i view the page without keeping the in CI view folder,but when i keep the root folder in the CI's view folder,i can only see the text of view.php, its not included css and images.( there is no prob in controller,i have called the view file from controller.)

how can i solve it,or what initiative should i have to take for desired result ?

Tanvir.
#2

[eluser]wemago[/eluser]
i cant get what u'r asking, but i assume its something like this
u've set the folders something like this,
- system
- css
- images

right?

now u have an image at the view file,

- system/application/view/viewfile.php

right?

i usually do something like this
Code:
<img src="&lt;?=base_url();?&gt;images/imagename.jpg" />

dont forget to load the url helper. -> http://ellislab.com/codeigniter/user-gui...elper.html

u can do this for js and css too

Code:
&lt;link rel="stylesheet" href="&lt;?=base_url();?&gt;css/style.css" type="text/css" media="screen" /&gt;

this should work perfect.
hope this is what u wanted.
#3

[eluser]Unknown[/eluser]
hi

the thing is something like you have described ,but my directory structure are as following:

application
---view
------images
------CSS
------view_page.php

in view_page.php i gave the image source in the classic way
Code:
<img src="images/item_printer.gif" width="167" height="164" alt="Sub Item Name" />

but its not working in CI.

i have also followed your instructions but till now its not working.

[quote author="wemago" date="1187817170"]i cant get what u'r asking, but i assume its something like this
u've set the folders something like this,
- system
- css
- images

right?

now u have an image at the view file,

- system/application/view/viewfile.php

right?

i usually do something like this
Code:
<img src="&lt;?=base_url();?&gt;images/imagename.jpg" />

dont forget to load the url helper. -> http://ellislab.com/codeigniter/user-gui...elper.html

u can do this for js and css too

Code:
&lt;link rel="stylesheet" href="&lt;?=base_url();?&gt;css/style.css" type="text/css" media="screen" /&gt;

this should work perfect.
hope this is what u wanted.[/quote]
#4

[eluser]Akademik[/eluser]
I strongly suggest you dont put your image and CSS/JS files in the views (sub)folders.
Place them outside of the "system" folder.
#5

[eluser]alpar[/eluser]
is there a reason why you suggest that Akademik, i was doing that too but this post made a point for me, there are some scenarios when i think it would make sense to put some CSS or images in the views section. Is there any serious drawback fro doing this?
#6

[eluser]Akademik[/eluser]
I dont actually see many advantages by doing that myself and i think that decoupling view code and resource files is a very nice way of organizing things. Its also a good practice to do that.
Ofcourse nothing will actually break if you still want to package your resources with view files.
#7

[eluser]deviant[/eluser]
Well there is also the fact that some people like to place their system folder outside of the web root, which would then render the resources in the view folder useless, as they have to be in a web-accessible directory.
#8

[eluser]IkoTikashi[/eluser]
[quote author="Tanvir." date="1187818704"]i have also followed your instructions but till now its not working.[/quote]
Have you set your "base_url" in /system/application/config/config.php"? Also, in the view, just print out &lt;?=base_url()?&gt; to see if it is set correctly.




Theme © iAndrew 2016 - Forum software by © MyBB