I had to implement this solution after i found two other solutions that did not suffice. One was incompatiable with jstree version 1.0 and the other didnt allow for tree manipulation. This extenstion allows for both.
This extenstion is set up as a widget and you can change the plugins and themes by sending params to the widget.
I also had to change the jstree backend to allow copying of nodes. (i.e. copy group C from group B and paste group c under group A. Add a site to Group C under Group B, then Group A's Group C will also contain that site... they are tied to the same object.) While others may not need this i think this can easily be changed by just recopying the back end, the class.tree.php file, with the original file. I have not tested it but i believe it should work.
If you wish to keep the current db/table setup but want different table column names you just have to change the lines in class.tree.php in the constructor where i list them. That way wherever they are referenced in the rest of the file it will pull the correct name.
I changed class._database_i to not need the original config.php and made it pull the db settings set in main.php to keep db setting consistency.
Requirements ¶
Yii 1.1?
jstree pre 1.0 fixed? (Dont know if it works with any other versions. I haven't used/tested anything else.
Usage ¶
To use: Download the dbscripts.zip and run them on your database to create the tables and data to get you started. Download the jstree.zip and put that entire folder and its contents in your extensions folder. Then put the following controller and view code in your appropriate controller and view files. Make sure the server variable for the widget is pointing to the correct action url for the controller.
in my controller I have
public function actionJsTree($operation = null, $id = null, $position = null, $ref = null,
$title = null, $type = null, $onlyone = null, $copy = null)
{
include('protected/extensions/jstree/_demo/server.php'); //sends data to the jstree server file which calls jstree
}
In my view file I have
<?php $this->widget('application.extensions.jstree.JsTreeWidget',
array('server'=>'./index.php?r=admin/sites/jstree', //points to the controller action
'plugins'=>array('contextmenu'=>true, //more plugins can be used here
'hotkeys'=>true,
'search'=>true),
"themes" => array("theme" => "apple",
"dots"=> true,
"icons" => true)
)
); ?>
Compatibility
Cannot be used without nested sets and uses an own database class to connect itself to the DB. Why should it not use Yii?
RE: Compatibility
It can utilize yii db.. I just did this in class_database_i to keep the db info the same...
function connect() { list($servername, $database) = explode(";",Yii::app()->db->connectionString); //get yii databse info for consistency $this->data = new mysqli( str_replace("mysql:host=","",$servername), Yii::app()->db->username, Yii::app()->db->password, str_replace("dbname=","",$database), $this->dbsettings["serverport"] );
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.