Help test gii: a web-based code generator

I don’t understand your problems.

If you only want to customize the templates for an existing generator, you should only add those template files as I described. Do not copy any other files (such as ModelCode.php, ModelGenerator.php). I just tested this without any problem.

If you want to change the code model and generator, then you need to either extend existing ones or write your own. This is less common.

What is the problem with using “/layouts/main”? If you use “gii.views.layouts.main”, you won’t be able to theme it.

As a feature request… in Cake there was a feature to ‘bake’ all models and crud… it would be nice if there was 1 button to click to create all models + crud in a databases as shortcut.

Oh, template files ONLY, thanks ;)

I think we got some misunderstanding here. I created a yii theme with the files from webapp skeleton, CSS, JS and views.

I want to have the ability to test all new features from yii within my app without a messed up layout.

So if I want to run gii now, it takes the view main.php from webapp skeleton (from the theme) and this one needs breadcrumbs and menu as a property, which gii’s DefaultController does not have.

And I am able to theme gii with the above solution, here is my directory layout:


/Users/tobias/Webserver/NetBeans/p2-template/www/themes/yii-1.1

Kraftbuch-4:yii-1.1 tobias$ tree

.

|-- css

|   |-- bg.gif

|   |-- form.css

|   |-- ie.css

|   |-- main.css

|   |-- print.css

|   `-- screen.css

`-- views

    |-- gii

    |   `-- layouts

    |       |-- column1.php

    |       |-- generator.php

    |       `-- main.php

    |-- layouts

    |   |-- column1.php

    |   |-- column2.php

    |   `-- main.php

    `-- site

        |-- contact.php

        |-- error.php

        |-- index.php

        |-- login.php

        `-- pages

            `-- about.php



Or maybe "layouts/main", without a leading slash?

Best regards,

schmunk

Thanks. I have fixed this bug.

They’re working really great now. In phundament beta 7 I’ve created a yii-theme, so I am able to run my app in the same style like the webapp skeleton.

If someone is interested, this is the complete directory layout of the yii-theme.


.

|-- css

|   |-- bg.gif

|   |-- form.css

|   |-- ie.css

|   |-- main.css

|   |-- print.css

|   `-- screen.css

`-- views

    |-- cms

    |   |-- default.php

    |   `-- simple.php

    |-- gii

    |   `-- layouts

    |       |-- column1.php

    |       |-- generator.php

    |       `-- main.php

    |-- layouts

    |   |-- column1.php

    |   |-- column2.php

    |   `-- main.php

    |-- p2

    |   `-- layouts

    |       `-- cms.php

    |-- site

    |   |-- contact.php

    |   |-- error.php

    |   |-- index.php

    |   |-- login.php

    |   `-- pages

    |       `-- about.php

    `-- srbac

        `-- layouts

            `-- column1.php



You can download it here:

http://phundament.com/en_us/blog?postId=50&postName=en-blog-A_yii_theme_for_yii

One more thing, I tried gii with the theme above.

I updated the generated controller from default CRUDs after creation with gii.


public $layout='column2';

Now it will use the layout from the theme folder.

A bit more about this: http://www.yiiframework.com/forum/index.php?/topic/4240-module-phundament-2/page__view__findpost__p__43306

I think modules such as gii should not use absolute paths to layouts and views, otherwise you won’t be able to overwrite them in a theme, which may lead to problems, or said the apposite way: themes can do some really nice things for you.

What do you think? Is there a need for absolute paths or do I overlook other problems here, because using the short way also worked for me in the webapp skeleton.

Best regards,

schmunk

Cool, thanks for the update.

I got another question …

Is it possible to specify the database for building in gii?

I thought about setting the connection in a base class, but haven’t tried it.

And just a note: Search does not work with jquery-1.3.2, just in case somebody else has also a updated scriptMap.

While playing around with the old ModelCommand I did this little update:

ModelCommand, line 153:

from


$this->_relations[$className1][$relationName]="array(self::MANY_MANY, '$className0', '$unprefixedTableName($pks[0], $pks[1])')";

to


$this->_relations[$className1][$relationName]="array(self::MANY_MANY, '$className0', '$unprefixedTableName($pks[1], $pks[0])')";

By switching the the unprefixed tables names the Relation widget is able to detect a relation in a correct way.

Just another 2 cent.

[edit]

Another problem I stumbled upon are the private variables in ModelCommand.

I’ve extended ModelCommand into P2ModelCommand, and overwrote generateRelations() but with private vars I am not able to use it. Protected ones are no problem.

Feature proposal: Comments, Commands, Components

What do you think about the ability to set custom input components or widgets in database comments?

Like this:


Custom Tags {yii:{func:'MyHtml::slider',2,5}}

Would create this code:


MyHtml::slider($model, 2,5)


Custom Tags {yii:{class:'MyInputWidget',prop:'foo',bar:'bar'}}

Would create this code:


$this->widget('MyInputWidget',array('model'=>$model,'prop'=>'foo','bar'=>'bar'))

Nice :rolleyes: ,

Though i’ve already gotten used to yiic , it’s my #1 reason for opening a terminal :D

will test gii as soon as i finish a couple of extensions i’m working on.

solved

I’m using Apache2 on Ubuntu Lucid and it works when I run Apache as the default www-data user and group. However, when I change this to a regular user (with sudo rights) in /etc/apache/envvars, I can no longer login to Gii. The webserver runs fine though…

(in case you’re are wondering why I want to change the webserver user: it’s a development machine and I don’t want permission issues between the webserver and the development tools I’m using to write code. This way all the /var/www files and directories are owned by the user I’m logged in to the GUI so I can do direct editing, and the webserver can do its file/directory actions.)

Some thoughts about CRUD layouts with blueprint CSS framework:

http://phundament.com/en_us/blog?postId=55&postName=en-blog-Super_CRUDs

Hi Qiang,

I’m new to Yii. However, I have followed the books to start learning Yii.

While I tried to generate model(s) from GUI (Gii), I don’t know it’s a bug or not, but I put the table prefix (e.g. “tbl_”) in the model generation form, and type-in the suffix of table name (e.g. Project) (i.e. table name is “tbl_project”), but error occurred.

It prompted the table "Project" not exist.

However, if no prefix was put, and put the whole name of the table (i.e. "tbl_project"),

it could find the table from the db-connection.

Can you tell what’s happen?

Hi Qiang,

I found the problem I met.

I just guessed the table name field only filled in the suffix!!

The table field should be filled the whole table name.