nestedsetadmingui

Nested Set Model Administration GUI with jsTree plugin.
24 followers

Overview

This extension includes

  • Gii Model and Crud templates that generate a graphical user interface (tree) for nested set model administration.With the help of jstree and fancybox plugins,all CRUD operations on a nested set model are reduced to context menu selections.Available operations appear in a context menu which opens when a node in the tree is right clicked.Nodes can be moved around in the tree with simple drag and drop actions.The overall feel approximates a desktop experience.

  • A Demo.

Try Out A Demo

Nested Set Admin GUI in SK Yii Test Lab

Requirements

Tested with Yii 1.8,will probably work with older versions too.

Installation

  • Hide index.php from your requests,if you have'nt done so yet.You can find detailed instructions on how to do this here.(Paragraph 6). Also,in urlManager configuration in config/main.php file set
'urlFormat'=>'path',
'showScriptName'=>false
  • Unzip the downloaded file.
    • Copy the gii folder to your application's protected folder.
    • Copy the js_plugins folder to the root folder of your application,(same level as protected).
    • Copy the client_val_form.css file and images folder to your application's css folder.
    • Copy the nestedBehavior folder to your application's extensions folder.
  • In config/main.php file,in gii configuration, add the path of your gii folder like so:
'modules'=>array(
      ......
          'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'password'=>'1',
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters'=>array('127.0.0.1','::1'),
                        'generatorPaths' => array(
                        'application.gii'  //nested set  Model and Crud templates
             ),
        ),
 
        .......
    )

Demo Installation (Optional)

  • Open the Demo Folder.
  • Import product_table.sql and categorydemo_table.sql in your database.
  • Copy the models,controllers,and view files found in the Demo folder to the corresponding folders of your application.
  • Navigate to [application root]/categorydemo] and you should see the administration page.

Usage

  • Prepare your Nested Set Model table structure. Use the contents of nestedSetAdminGUI.sql file as a basis.All columns stated in this file are required for the extension to work-you can add your own columns.You can change the name of the table,it will become the model class name in the generated files.

IMPORTANT:Use a simple name for the table,all lowercase and no underscores,hyphens and the like.

  • Import the table in your database.
  • Navigate to gii page ([application root]/gii).
  • Click Model Generator.
  • Type the table name in the Table Name field.
  • Click on the Code Template and select nested.Preview if you want,and then Generate.
  • Your nested set Model class has been generated.

IMPORTANT:Open the newly generated model class file and remove ALL rules associated with Nested Set Behavior columns: rgt,lft,root,level,id.No rules should appear for these columns.

  • Click Crud Generator
  • In the Model Class field type the name of the class that was generated in the previous step.
  • Again,click Code template and select nested,if it's not already selected.
  • Preview if you want,and then Generate.
  • This is it.Navigate to the controller URL .For example if you used the default table name category,go to [application root]/category.You should see the administration page and you are ready to create roots and nodes.

Cheers. Spiros "DrumAddict" Kabasakalis,September 5th 2011.

Resources

Total 10 comments

#7912 report it
Karasko at 2012/04/25 10:02pm
@drumaddict

No critics, i appreciate your piece of work. And this isn't just a piece of code i took from you, this is published as an extension, i think you are also interested in quality of your code... just be sure using undefined variables always been evil not depending on whether it on production, or with any error_reporting level set. Took it is a advice pls. Cheers

#7893 report it
drumaddict at 2012/04/25 04:19am
@Karasko

You should be able to make all the changes to the code to serve your needs.Stop whining and don't expect that other's code will suit your needs out of the box.On production server nobody uses warnings in error reporting,it suits me.If you want it some other way,modify the code.Last advice,stop criticizing other's extensions when you have never developed a single one.Learn to appreciate and respect.

#7887 report it
Karasko at 2012/04/24 08:42pm
The installation includes bugfixes process )

Drumaddict At 2012/04/13 02: 48am @saegeek Try lowering your error reporting level to something less than strict whata bad advice

drumaddict, i'm interested in your extension. Unfortunately in setup process, i understood, that your error_level_repoting when you wrote it was so low, that i got not one error installing demo with my error_level_reporting=E_ALL (which consists also of E_NOTICE - that one very useful for DEVELOPMENT process, though may be security risky in PRODUCTION - as i know due to much info may revealed).

So if you plan to support this extension, i suggest that you should write it with E_NOTICE enabled... Not to mistake with E_STRICT - will not help in this case, definition of vars are checked by E_NOTICE

Anyway i'm sure your ext will help me to deal with jsTree obscure methods params. Thanks

#7733 report it
drumaddict at 2012/04/13 02:48am
@saegeek

Try lowering your error reporting level to something less than strict

#7732 report it
saegeek at 2012/04/13 02:34am
bug

In the demo, when i click "Create Root" nothing happens and Firebug says : PHP Error 500: Undefined variable: updatesuccess (/var/www/protected/views/categorydemo/_form.php:55

#6440 report it
sxtuwy at 2012/01/10 07:14pm
Remove after updatesuccess variables, but also in other mistakes. Please look below

Remove after updatesuccess variables, but also in other mistakes. Please look below

PHP Error [8]

Undefined index: name (D:\KuPan\wamp\www\mytree\protected\views\category\_form.php:122)

Could you put the web for the latest code issue: http://libkal.gr/yii_lab/categorydemo, thank you

#6423 report it
drumaddict at 2012/01/09 02:06pm
@sxtuwy

No big deal,this is a variable that was no longer needed and forgot to remove.Just delete it.If the error reporting is not STRICT,there will be no exception raised.

#6421 report it
sxtuwy at 2012/01/09 10:10am
I found a mistake

PHP Error [8]

Undefined variable: updatesuccess (D:\KuPan\wamp\www\mytree\protected\views\category_form.php:54)

#5339 report it
drumaddict at 2011/10/05 03:49pm
@pokok

I can only guess:You probably used a weird name for your model and the generator messed up,because the model name is used to name the ADMIN_TREE_CONTAINER_ID constant.Avoid names like MyModel,My-Model,My_Model,(and other characters separating My and Model).Try Mymodel. Again,it's only my guess.If the problem persists,mail me (from my profile).

UPDATE:It's the error reporting settimg in your php.ini,exclude warnings.

#5338 report it
pokok at 2011/10/05 03:25pm
Thanks

Hi drumaddict, thank you for your great work. I followed your instructions step by step but I get an error creating the crud (model generator works fine). Use of undefined constant php - assumed 'php' /WebRoot/myapplication/protected/gii/crud/templates/nested/index.php(181) Any solution? Thanks again

Leave a comment

Please to leave your comment.

Create extension