Welcome Guest, Not a member yet? Register   Sign In
CI and ExtJS setup
#1

[eluser]anjelika[/eluser]
Hello,
I am a novice CI user but not so novice PHP and ExtJS one.
I was looking to use ExtJS (nice Javascript UI library, btw) together with CI (using Ext for views and some ajax functionallity).
Trying to load my javascripts from the view (login.php) does not seem to work, even tho I supply the right path to the js files.
E.g.:

In controller I have this:
/system/application/controllers/start.php

Code:
<?php
class Start extends Controller {
        
    function index() { //here I load the login view
                
        $this->load->view ( 'login');
        }
?>

now, system/application/view/login.php contains the following code:

Quote:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
&lt;title&gt;Telcor Web2SMS - Autentificare&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="C:\wamp\www\CI\ext-2.0.2\resources\css\ext-all.css"&gt;



&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;

I used absolute path just to make sure that the javascripts are loaded (and they are, by looking at Firebug debugger), but nothing is desplayed on the page (still no errors trown).
The last js called login.js should display the login box, but I think I'm missing something here or this may not be the best way to call the js from views.
Thanks

P.S. I don't know why I can't post the js code contained in the view, it appears OK in the preview mode but not showing when posted, so here it is...

Code:
<sc type="text/javascript" src="C:\wamp\www\CIext-2.0.2\adapter\ext\ext-base.js"></sc>
    <sc type="text/javascript" src="C:\wamp\www\CI\ext-2.0.2\ext-all.js"></sc>
    <sc type="text/javascript" src="C:\wamp\www\CI\system\application\views\javascript\login.js"></sc>
#2

[eluser]Doosje[/eluser]
You need to point it to the 'web'directory in you're browser
http://localhost/test/ <-- then you could tell like this
Code:
&lt;link rel="stylesheet" type="text/css" href="/test/ext-2.0.2/resources/css/ext-all.css"&gt;
#3

[eluser]anjelika[/eluser]
You mean I need to make the includes relatives to my web server app?
Is there any other way to include and display this?
Thanks
#4

[eluser]Doosje[/eluser]
in the template where you call the css you can type:
Code:
&lt;link rel="stylesheet" type="text/css" href="&lt;?=basepath;?&gt;/ext-2.0.2/resources/css/ext-all.css"&gt;
if i'm correct
#5

[eluser]gunter[/eluser]
Anjelika, it´s evil to load something externally from your view folder!!! :bug:
there are numerous post about where to put css, js and pictures, the most of them are using an assets folder near the index.php, or so...
#6

[eluser]anjelika[/eluser]
Thanks for the help, guys....where to put the resources and js file was another issue of mine.
I have the book about CI, nice one , btw...but I think I'll start with the online help first.
I've been using symfony in the past, which is a nice framework, but CI seems more lightweight and mor suitable for smaller (not so complicated) projects.
Still, there are some MVC implementation diffrences between these two which I have to make clear before going deeper into CI.
#7

[eluser]outrage[/eluser]
I use a 'resources' (call it what you want) folder off the root.


/webroot/
/webroot/index.php
/webroot/system/
/webroot/resources/extjs/
/webroot/resources/images/



I dont think that's the problem with your page though. If you can see the Javascript files are loaded in Firebug, then there is probably an error in your code if the page won't display.
#8

[eluser]anjelika[/eluser]
That's right, the files are loaded successfully, even if I place an alert into the js file containing my ext code, this works, but it does not render anything on the page...I will take a further look into this...thank you!
#9

[eluser]outrage[/eluser]
If you post the login.js file I may be able help more, but you may be better off posting on the ExtJS forums since it isn't a CodeIgniter issue and their don't appear to be many ExtJS users in these forums. Smile
#10

[eluser]anjelika[/eluser]
Thanks,
The login.js works outside the CI, it is a working version that I used for this test.
I will give it another try tonight and let you know the results after.
Thanks




Theme © iAndrew 2016 - Forum software by © MyBB