Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter and jsTree integration
#1

[eluser]JuanG[/eluser]
Hello CI community,

I've been trying for a while to make jsTree work inside a CI project but it's been impossible so far for me.

I did some tests with the jsTree demo in a regular, old fashion website (everything on a couple of directories) and it works nice, but I haven't been able to make it all work within the structure of CI. I made a bit of progress with help of Firebug but nothing relevant at the end.

Have any of you accomplished this task already?

I don't have a particular error to show you, just different errors and warnings, mainly from the several include files jsTree requires.

So far I just get an ajax fan of "Loading ..." and no tree or icons displayed.

I changed a few things in the js code like ./server.php by module/server and created the proper server() function inside the module controller but that just fixed the first of many errors.

To give you a better idea of what I'm seeing, I'm posting a couple of pictures here of my two local installations. The one with the jsTree working and the one inside CI that doesn't work. It seems to be a problem with the includes of the _inc folder inside jsTree.

1) Working

2) Not working

If you can give me some guidance I'll be extremely thankful to you guys.

Cheers,
#2

[eluser]Rys[/eluser]
[quote author="JuanG" date="1280629359"]
I've been trying for a while to make jsTree work inside a CI project but it's been impossible so far for me.
[/quote]

Juan,

Here's solution that seems to be working for me (CodeIgniter 1.7.2, jQuery 1.4.2, jsTree 1.0rc2).

1. You will need two slightly modified jsTree classes (attached); put them into your "libraries" directory.
2. You will also need AjaxTree controller for Ajax requests support (attached); put this file into "controllers" directory.
3. Modify JstreeDatabase.php to match your database settings (server name, database etc.)
4. Create database structure as required by jsTree (sample SQL attached)
5. Apply changes to JavaScript setting up jsTree - find & replace every URL in Ajax, make sure it uses your AjaxTree controller:
Code:
"url" : "/admin/ajaxtree/tree"

Good luck Smile
#3

[eluser]Krzemo[/eluser]
My advice is to skip PHP code provided with JSTree and start from very beginning. This way you will be able to fully understand how it all works.
Are you familiar with storing and manipulating hierarchical data in DB? Have you already chosen a way to feed your tree with data? Is it going to be a JSON, HTML, XML? Do you know what functionalities (plugins) provided with JSTree you will need?
Set up JS part correctly in simpliest possible way and then create a dummy controller returning fixed feeding data. See how it all works, how data structure affects tree appearance etc (i.e. rel attribute). Dig into it and develop by adding and fixing things.
And then if you have specific questions I can try to help you.

Regs
K.
#4

[eluser]Unknown[/eluser]
Could someone please attach files one more time. Or working example Jstree with Codeigniter.

I have created new Controller and methods Server and Config which is used in Jstree. Also created models for files included in _inc folder for Jstree structure and Jstree DB

I have done also step 3,4,5 from Rys's post:

Can't do step 2, because attached file doesn't work:
Where to find more information about AjaxTree?
Quote:2. You will also need AjaxTree controller for Ajax requests support (attached); put this file into "controllers" directory.

At this moment i have this error in firebug:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: show_error
Filename: models/jstree_db.php
Line Number: 121
http://img594.imageshack.us/img594/4654/capturezjr.png
#5

[eluser]Unknown[/eluser]
hello every one

I can run jstree alone at localhost but i want to use jstree at ci

can someone share files again?

thank you all




Theme © iAndrew 2016 - Forum software by © MyBB