Forum

Home » support » General discussion » Building Own Generator  (4) 6 Vote(s)
Re: Building Own Generator [message #34794 is a reply to message #34764 ] Mon, 03 September 2007 08:59 Go to previous messageGo to next message
francois  is currently offline francois
Messages: 1553
Registered: October 2005
Faithful Member
Guys,

Reviewing code and working at several on the same codebase is much easier if you use the Subversion repository.

Could you please commit your code to the plugins repository and create a wiki page about it? Smile
Re: Building Own Generator [message #34813 is a reply to message #34794 ] Mon, 03 September 2007 11:27 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
I agree about the SVN, I send Fabien an e-mail and asked him for an svn account. I again already made some improvements, and I don't want to package it everytime I do this Wink Besides I don't want to keep on merging everyones improvements, if they can do that themselves...

I also tried to package the project in a pear-package, but for some reason it gives my package the name symfony-0.0.1.tgz, instead of sfExtjsThemePlugin-0.0.1.tgz, while my package.xml file contains the line:

 <name>sfExtjsThemePlugin</name>


All files I mention do get included, but I think it is "impossible" or at least un-do-able to also include all files of the ExtJs library in the package.xml file. Is their an easy way to generate this content part of the package.xml file?


Leon
Re: Building Own Generator [message #34863 is a reply to message #34764 ] Tue, 04 September 2007 01:30 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
The alpha-alpha release 2.

Lots of improvements, for example edit now works when you double-click an item, but nothing is finished yet (of course...)

The list options from your generator.yml file are now mostly seen back in the ajax-view.
The edit-view still needs lots of work, for example the actions need to be moved.

I found a serious issue regarding secuirty in the plugin: Even though I check for credentials, I send all (other) columns to the user in the ajax-json-result, which now can contain passwords, even though you don't show them in your list and you don't have an edit page... I still have to think about this, comments are welcome.

An other issue can be seen with the sfGuardPlugin. This plugin uses images to show if a user is_active, but this makes the results disappear in your ajax-view.

I don't have the svn account yet, so for this time again a tar.gz:
http://fun4me.demon.nl/~leon/sfExtjsThemePlugin-0.2.tar.gz 3.2MB

Please read the README!!!

I would still be very happy if someone can figure out a way to enable multi-column sort in extjs. It now does work with the ajax-view. But you don't see it.

Other feedback is of course appreciated.

I merged a part of the work of Wolfgang Kubens, but because the panelLayout fills the entire page, it overwrites your default layout. I now show the edit page in a modal dialog.
If I know why the panelLayout overwrites all other divs I will implement the panel solution too.

I will now focus on actions and master-detail

[Updated on: Tue, 04 September 2007 01:42]


Leon
ExtJs powered Generator [message #34894 is a reply to message #24107 ] Tue, 04 September 2007 13:05 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
this is really cool:

http://aariadne.com/accordion/accordion.html?showGrid=true

I also found out that the multi-select columns are probably possible by extending (or enhancing) the extjs library, but I haven't got time to figure that out more precisely. I think it should be possible with something like Ext.apply(....


Leon
Re: Building Own Generator [message #34917 is a reply to message #24107 ] Tue, 04 September 2007 19:37 Go to previous messageGo to next message
KRavEN  is currently offline KRavEN
Messages: 154
Registered: May 2007
Senior Member
I've been working with Kubens generator. Anyone know why this will only copy over php files?

<?php
$finder 
pakeFinder::type('any')->name('*.pjs''*.php''*.yml');
pake_mirror($finder$tmp_dir.'/auto'.ucfirst($module), $module_dir);
?>

Re: Building Own Generator [message #34959 is a reply to message #34779 ] Wed, 05 September 2007 12:19 Go to previous messageGo to next message
DrCore  is currently offline DrCore
Messages: 59
Registered: August 2007
Member
A new day, a new release.

New is a master-slave or subform setup setup. It takes care of hiding values which are not connected to the master and it will make sure the master value is added when creating or editing a new record.

Check the README for further details.

Andre

Re: Building Own Generator [message #35118 is a reply to message #34917 ] Fri, 07 September 2007 00:45 Go to previous messageGo to next message
KRavEN  is currently offline KRavEN
Messages: 154
Registered: May 2007
Senior Member
I figured out the problem. I needed to override the entire generate function in the crud generator to add the new extensions to the finder there before the files are copied from the template to the tmp directory

I've gotten quite a bit done on kubens ext crud generator. I think it will go well with the ext admin generator.

I've added an extJs helper plugin and a sfPCSS plugin very similar to the sfPJS plugin. Together with the sfPJS plugin I've gotten all the php files split out into javascript, css, and html templates. I like the ability to keep my javascript, css, and html code seperated.

I've only got a few more things to add like create a pake task, make the generator a proper module, and add the ability to change the generator file and not have to regenerate.

The ability to not need to regenerate on generator.yml changes will give some of the advantages of an initiated crud but also provide the ability to customize the source. This will probably come as a helper functions in my extJs helper plugin.

[Updated on: Fri, 07 September 2007 00:46]

Re: Building Own Generator [message #35905 is a reply to message #24107 ] Tue, 18 September 2007 20:27 Go to previous messageGo to next message
DrCore  is currently offline DrCore
Messages: 59
Registered: August 2007
Member
The CustomAdminGenerator plugin has been updated with some new functions and enhancements:
- More then one filterlink active
- helper function for admin list forms
- alignment of values in list forms
- specify type of filters

More functions will pop-up soon.

Andre

Re: ExtJs powered Generator [message #36876 is a reply to message #34894 ] Sat, 06 October 2007 10:52 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
Although I was a little quiet, that was only because I'm still working hard on the Extjs plugin. Extjs2.0 Alpha has been released and this are my results so far:

http://fun4me.demon.nl/~leon/Extjs2.0a-Master-Detail.png

The master-detail capabilities are almost completely implemented, as you can see. (One Assignment can contain multiple Parcels) At the moment I show a mixture of Assignment- and Parcel-values in the columns, but it still in active development. (The total count at the moment is not correct, I intend to show the number of Assignments+Parcels, not only the Assignments, nor only the parels, because I think it is much harder to implement Wink In this case the total number will become 3+8=11 )

The in-list-editing does not save yet and edit-fields do not work yet, because I still have to start implementing it... What I also want to implement is that the Vessel names in this case, make use of autocompletion and become a drop-down-box, with the values of all vessels. No problems expected overthere, the only thing which I need is time. The errors which firebug shows are only warning, which show up when you edit a field in the list, this is a known bug in Firefox, but has no implications.

I still don't have a svn account, I think Fabien has forgotten about it. I think an SVN account would be appropriate when I finish the edit-view, I will get into contact with Fabien again at that time.


Leon
Re: ExtJs powered Generator [message #36882 is a reply to message #36876 ] Sat, 06 October 2007 13:12 Go to previous messageGo to next message
StarQuake  is currently offline StarQuake
Messages: 10
Registered: April 2006
Location: Netherlands
Junior Member
Wow, that is pretty!
Re: ExtJs powered Generator [message #36883 is a reply to message #36882 ] Sat, 06 October 2007 13:55 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
Thanks,

Actually there is some more: What I didn't mentioned was that this (eventually) can be generated with only the generator.yml file.

I am not going to tell you when I am finished, because I seem to fail in predicting that, but I can tell you I am almost there.

At the moment you can define which fields are editable (as you can see, the columns created_by/at and updated_by are italic, which I use to show you cannot edit them. The Subject is a link to the edit-view for the detail, which is simply created by defining =parcel_subject in the generator.yml file... Just like it currenty is the case for ordinary lists.


Leon
Re: ExtJs powered Generator [message #36942 is a reply to message #36883 ] Mon, 08 October 2007 08:45 Go to previous messageGo to next message
francois  is currently offline francois
Messages: 1553
Registered: October 2005
Faithful Member
lvanderree,

You should contact Fabien directly by email to tell him about your SVN account. He should be able to open you commit access to the plugins repository right away.
Re: ExtJs powered Generator [message #37014 is a reply to message #36942 ] Tue, 09 October 2007 02:35 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
I mailed Fabien today and he fixed me an account,

Before I submit the plugin to the svn I have to finish the generator code for the javascript extjs-grid. This requires minor changes so it can handle the added master-detail functionality. My JSON (data output) implementation is already equipped for this.

To get master-detail overview, you can make generators which look like this: (A (master) Assignment can have multiple Assignmentparcels as detail)

The code for the JSON implementation isn't pretty, I had to copy the content of methods from the generator into my partials. See my post at http://www.symfony-project.com/forum/index.php/t/9131/
If you know an answer to this problem, please give me some hints.


generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      Assignment
    theme:            extjs
    
    sub_class:
      model_class:    Assignmentparcel
      display:        [ =subject, sf_guard_user_related_by_created_by, created_at, sf_guard_user_related_by_updated_by, updated_at  ]
      fields:
        subject:
          summary_type: 'count'
          summary_renderer_function: "return ((v === 0 || v > 1) ? '<b>' + v +' Parcels</b>' : '<b>1 Parcel</b>');" 
        sf_guard_user_related_by_created_by:
          name: Created by
        sf_guard_user_related_by_updated_by:    
          name: Updated by
    
    list:
      title:            Assignments
      multisort:        false
      display:          [ =subject, client, vessel ]
      grouping:
        field:          assignmentid
        plugins:        summary
      fields:
        vessel:
          join_fields:  [AssignmentPeer::VESSELID, VesselPeer::VESSELID]
          sort_column:  VesselPeer::NAME



I think you can expect the initial svn-submit tomorrow, but I don't promise anything...


Leon
Re: ExtJs powered Generator [message #37015 is a reply to message #37014 ] Tue, 09 October 2007 02:44 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
Ps. the plugin and summary data you see are Extjs functions which calculate and show the count below every assignment.

Ps2. As you can see both Assignment as well as Assignmentparcel have a field 'subject', but that is no problem (I generate prefixes), but this does however require some extra work to make sorting work. That will probably be the reason I won't make it tomorow to commit already.

Edit functionality will be implemented later.


Leon
Re: Building Own Generator [message #37170 is a reply to message #24107 ] Wed, 10 October 2007 20:39 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
I should have known better, I am still not ready for comitting to svn.

After my last post my computer died on me...So yesterday I tried to find out what and why and narrowed it down to my motherbord or CPU. Today I went back to the shop and they say it is my motherbord and are going to exchange it, after first sending it back to their supplier (which takes at least a week).

Luckily I've got myself an other computer in the meantime and thanks to Linux which boots just as easily on this AMD64 as on my Intel Dual-Core I can continue my work without further problems (I hope)...

Keep you posted.


Leon
Re: Building Own Generator [message #37248 is a reply to message #24107 ] Thu, 11 October 2007 16:26 Go to previous messageGo to next message
raslam  is currently offline raslam
Messages: 50
Registered: January 2007
Location: Pakistan
Member
Kubens,

you have done a great job and lvanderree's contribution is very appreciated.

i am also new to symfony but to think about this kind of work, it needs greater knowledge of symfony framework.

I am also trying to digg in framework. Where u studied all the framework? once i get some hands on I'll also try writing some plugins.

Good luck to you guys.

--
raslam


--
regards,
raslam
Re: Building Own Generator [message #37251 is a reply to message #37248 ] Thu, 11 October 2007 16:38 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
I started with creating the http://www.symfony-project.com/doc/1_0/"My First Project", getting the feel of the directory structure and the possibilities of the admin generator. But you probably already have some idea about this.

After this I tried to create my own proofs of concepts; creating an application without modifying anything. If you get this far you probably mis some features, and I used the book to find out how to get things done/are things done. I found out that extending baseClasses, basePeers and adding components and partials is pretty powerful.

But eventually you want more and more, and at that time I think it is time to dive in the symfony-lib code. Finding what you need can sometimes be a little hard, I usually use a search tool to search through the entire symfony-lib for specific variable- and function-names.

Another great source of information is of course this forum and the snippet pages. The first modifications I made to my new Theme where based on snippets, which I generalised and extended.


Leon
Re: Building Own Generator [message #37256 is a reply to message #24107 ] Thu, 11 October 2007 17:19 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
At the moment I think I am ready for the initial commit to the svn, but I found out my svn account isn't working... Or I am doing something wrong (have email Fabien again this morning, so we have to wait for him now).

The new (Extjs) features which are working for now:
  • Transform your list into a Extjs-Grid.
  • Fields can be a link, can be editable, or read-only (defined in your generator.yml file)
  • Master-detail is working (but not recursive. so only 1 deep, first of all a limitation of the extjs-lib, but I did not prepared my code for it either)
  • Non-master-detail-lists can also be grouped. So you can for example have a list of cities, which you group by country.
  • You can disable the extjs-grid-view per module, in the generator.yml file. This cannot be done in "runtime" (yet), for example when a browser does not support javascript.
  • JSON data is created, respecting your credential settings. Also partials can be used.
  • Extjs plugins can be defined, for example to count the totals in a group. The plugins can be defined in a partial.
  • not Exjs, but working: you can sort columns on foreign-values and partial-values, by defining a sort-column in your generator.yml file.
  • also not Extjs specific, you have more control on the edit title. New object can now have an other title than the edit-object title. (can be done from the generator.)


What has to be done:
  • sorting in a master-detail view is not yet possible (work in progress, should not be too much work anymore).
  • Changing the sort order for the group-by-field is something which should be thought about, there is no gui-possibility for it at the moment in extjs, because the field on which you group-by, does not have a column.
  • If multiple fields of your master-object should be shown in the grid, you have to create a partial for it. Maybe it is nicer to let ExtJs combine the seperate fields from the JSON data.
  • Extjs does not support showing multi-sort columns (only one column can show if it is asc/desc, my symfony code can handle multisort.)
  • I haven't looked at filtering yet.
  • At the moment I define the fields of the detail-class (sub-class) in the (master-)generator.yml file, in a new section. Maybe it is nicer to define only the detail-class-name in this generator.yml file, and load the detail-display fields and all other settings from the detail-generator.yml file (in the detail-class directory). The problem is that I think the symfony-lib needs some changes.
  • At the moment I copied some code from the symfony-lib into my generator-theme-code, because I was not able to create an instance of some classes, This can be due to me, or because this is not supposed to be done by symfony (look for example at the It contains E.G. )
  • For now last, but certainly not Least: You can not edit your content. Edit-view has to be implemented, and editing directly in the list does not get saved. I also want to have auto-complete/drop-down lists for foreign fields. (E.G. In a list of cities with the country next to a city, the country-field should be a drop-down list of countries).


The two most important new files in the generator-theme:
  • _json_list_td.php contains the code for the JSON-data rows. Not so nice, it also contains the entire code to get the detail-data...
  • _list_ajax_layout.php file, creates the javascript grid code.


For now, pictures:

First non-extjs, with multisort on (sorry, I did not load the default css-file, which explains the broken heading):
http://fun4me.demon.nl/~leon/symfony-extjs/cities-multisort.png

now added
ajax: true

to the generator.yml file:
http://fun4me.demon.nl/~leon/symfony-extjs/cities-ajax.png

Now added grouping, by adding this to the list:
      grouping:
        field:          country
        plugins:        summary

http://fun4me.demon.nl/~leon/symfony-extjs/cities-grouping.png

The complete generator.yml file, no partials are used:
generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      City
    theme:            extjs
    
    ajax: true

    fields:
      name:             { name: City }
      countryid:        { name: Country }

    list:
      title:            Cities
      multisort:        true
      sort:             [ country, name ]
      display: 		[ =name, country ]
      filters:        	[ countryid ]
      grouping:
        field:          country
        plugins:        summary
             
      fields:
        name:
          summary_type: 'count'
          summary_renderer_function: "return ((v === 0 || v > 1) ? '<b>' + v +' Countries</b>' : '<b>1 Country</b>');" 
        country:
          join_fields: 	[CityPeer::COUNTRYID, CountryPeer::COUNTRYID]
          sort_column: 	CountryPeer::NAME

    edit:
      newtitle: Add new city
      title: Edit city "%%name%%"
      fields:
        countryid: 			
      display: [name, countryid]


ajax: true is default, ajax: false would disable the ajax view. If you don't want ajax-view in any page, you can also define ajax:false in the application.yml settings file (Or not use this theme). As said: multisort: true does not work with ajax:true, or at least is not usefull, because you don't know which column is used for sorting.
As you can see, I can sort on country-names, even though this is a foreign-field

[Updated on: Thu, 11 October 2007 18:05]


Leon
Re: Building Own Generator [message #37260 is a reply to message #24107 ] Thu, 11 October 2007 17:38 Go to previous messageGo to next message
raslam  is currently offline raslam
Messages: 50
Registered: January 2007
Location: Pakistan
Member
this is looking very good. theme and generator both are looking good.

keep up the good work.

--
raslam


--
regards,
raslam
Re: Building Own Generator [message #37279 is a reply to message #37256 ] Thu, 11 October 2007 18:54 Go to previous messageGo to next message
nbeck  is currently offline nbeck
Messages: 30
Registered: September 2007
Location: germany
Member

great work, lvanderree!

for my current project, i was about to reuse and modify a tree (nested set model, simple controller, ext frontend) i've made before, but now that i see your work, it seems to make more sense to add this functionality into your plugin. Can't await to grab a fresh copy of it from svn Smile

Or does your current version already support trees?

best regards,
Normen
Re: Building Own Generator [message #37283 is a reply to message #24107 ] Thu, 11 October 2007 20:14 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
It has been done!

go check it out at http://svn.symfony-project.com/plugins/sfExtjsThemePlugin/

I hope you people can make some great improvements to it. (for example code clean-up).

I am going to fix the sorting for master-detail pages.


Leon
Re: Building Own Generator [message #37287 is a reply to message #24107 ] Thu, 11 October 2007 22:55 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
Extjs 2.0 Beta1 is out, and already included in the svn.

For info about Extjs 2.0 Beta1, see: http://extjs.com/blog/2007/10/11/ext-20-beta-1/


Leon
icon11.gif  Re: Building Own Generator [message #37378 is a reply to message #24107 ] Sun, 14 October 2007 01:33 Go to previous messageGo to next message
Pete  is currently offline Pete
Messages: 5
Registered: October 2007
Junior Member
Guys, this looks so awesome good. I am trying for about 5 hours now to get it running. I tried both with the 1.0 and TRUNK but it didnt work. Please specify which versions of symfony and extjs you use.

May be someone could set up a symfony-extjs-sandbox?

Thanks!
Regards
Pete
Re: Building Own Generator [message #37379 is a reply to message #37378 ] Sun, 14 October 2007 01:40 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
Can you be somewhat more specific what goes wrong?

I'm using Symfony 1.0.8, but I think it should work with Symfony 1.0.*

Extjs is included in the library, so if you do an svn checkout it should work.

Haven you checked the Readme, which says you should make a sym-link, or simply copy the contents of the the plugins/sfExtjsThemePlugin/web folder, to the project-web-directory/sfExtjsThemePlugin ?

And have you seen that you should define some stylesheets and javascript files in your applications layout.php?

[Updated on: Sun, 14 October 2007 01:41]


Leon
Re: Building Own Generator [message #37388 is a reply to message #24107 ] Sun, 14 October 2007 15:01 Go to previous messageGo to next message
Pete  is currently offline Pete
Messages: 5
Registered: October 2007
Junior Member
Okay it works (badly) without installing Extjs (may be one should mention explicitly that extjs actually is included).

The page is loading but only the header text is being shown. I checked the source and in the generated js there was the following:

<br />
<b>Notice</b>:  Undefined variable: group_field in <b>D:\Dev\mehsite\wwwRoot\cache\backend\dev\modules\autoLanguage\templates\_list_ajax_layout.php</b> on line <b>67</b><br />


I was able to workaround this by adding a @ in front of the statement at line 168 of _list_ajax_layout.php.

After this the page loads once. As soon as i reload the page it says:

[sfException]
Cannot sort on column "", the column does not exist.
stack trace
at ()
in SF_ROOT_DIR\cache\backend\dev\modules\autoArtikel\actions\actions.class.php line 283 ...
            catch (Exception $e)

            {

              // sort column does not exist, throw error

              throw new sfException(sprintf('Cannot sort on column "%s", the column does not exist.', $sort_column));

            }

            break;

        }
at autoArtikelActions->addSortCriteria(object('Criteria'))
in SF_ROOT_DIR\cache\backend\dev\modules\autoArtikel\actions\actions.class.php line 55 ...


I did cc all the time.

Thanks!

[Updated on: Sun, 14 October 2007 15:02]

Re: Building Own Generator [message #37389 is a reply to message #37388 ] Sun, 14 October 2007 15:20 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
Can you post your generator.yml file?

I think the problem lays there somewhere.

Please note that this plugin is still in active development, and not finished by far. But all feedback (comment/extensions/ideas) are welcome.

Last night I fixed the sorting. There is however a problem when you sort in grouped lists, which is probably due to extjs. I post a report on the extjs form and waiting feedback over there.

Currently I am working on fields having (related)dropdown-lists with autocompletion and other extensions. A sneak preview:

http://fun4me.demon.nl/~leon/dropdown.png


Leon
Re: Building Own Generator [message #37390 is a reply to message #37388 ] Sun, 14 October 2007 15:24 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
My first guess is that you have defined grouping, without a group field and without a list of columns which you want to display.

I don't think my code can handle grouping views, when you don't define display, nor grouping.field

Take for example my city generator.yml file:

generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      City
    theme:            extjs
    
    ajax: true

    fields:
      name:             { name: City }
      countryid:        { name: Country }

    list:
      title:            Cities
      multisort:        true
      sort:             [ country, name ]
      display:          [ =name, country ]
      grouping:
        field:          country
      fields:
        country:
          join_fields: 	[CityPeer::COUNTRYID, CountryPeer::COUNTRYID]
          sort_column: 	CountryPeer::NAME



In this case I define both, but at least one of them should be defined.

[Updated on: Sun, 14 October 2007 15:58]


Leon
Re: Building Own Generator [message #37393 is a reply to message #24107 ] Sun, 14 October 2007 20:18 Go to previous messageGo to next message
Pete  is currently offline Pete
Messages: 5
Registered: October 2007
Junior Member
I did not define grouping nor sorting. Actually i did not even had the ajax: true statement in the yml (i just added, it doesnt work).

I dont know why it thinks i want to sort or group.

Here is my yml:
generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      Artikel
    theme:            extjs

    ajax:               true


Edit: Okay i "fixed" this by inserting
if (!count($sort_columns)) break;

before line 588 in actions.class.php.

It now displays the list. But none of the functionality works - when i click "Add new Artikel" it doesnt do anything. I guess i missed includes?

My js includes are as follows:
    <script type="text/javascript" src="/sfExtjsThemePlugin/extjs/adapter/ext/ext-base.js"></script>

    <script type="text/javascript" src="/sfExtjsThemePlugin/extjs/ext-all-debug.js"></script>

    <script type="text/javascript" src="/sfExtjsThemePlugin/js/extGridGroupSummary.js"></script>
    
    <link rel="stylesheet" type="text/css" href="/sfExtjsThemePlugin/extjs/resources/css/ext-all.css" />
    <link rel="stylesheet" type="text/css" href="/sfExtjsThemePlugin/extjs/resources/css/xtheme-default.css" />

    <link rel="stylesheet" type="text/css" href="/sfExtjsThemePlugin/css/symfony-extjs.css" />


Instead of creating a symlink or copying the contents of the plugin-web-folder to the site-web-folder i created an alias in apache (i hope there are no fs-calls).

Regards
Pete

Edit 2: And whenever i click an item in order to edit it, i get to a style-less page with no <html>/<head> tags at all - i guess this should be displayed in a div instead but i get it as a regular page.

Btw. thanks for your support, Ivan.

Edit 3: I know copied the files as stated in the README, did not change anything. All the above included files are verified working.

I guess i missed something. None of the ajax-functionality works...

[Updated on: Sun, 14 October 2007 20:40]

Re: Building Own Generator [message #37394 is a reply to message #37393 ] Sun, 14 October 2007 20:25 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
ajax: true is optional, it is true by default, otherwise you probably did not use this theme.

I think I know what the problem is, it probably is (not surprisingly) in my code. I will take a look at it later this evening and test it with a minimal generator.yml file.

You can probably work around the problem, by setting a display field in the generator.yml file, with the columns you want to see.


Leon
Re: Building Own Generator [message #37399 is a reply to message #37394 ] Mon, 15 October 2007 02:48 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
I've changed the code a little, but actually more to improve the readability, I tested it with this very simple generator.yml file:

generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      Country
    theme:            extjs



Please tell me if it now also works out for you.

The error should not show up (any more), group_field is always defined in _list_ajax_layout.php (line 83).

$group_field = $this->getParameterValue('list.grouping.field', null); 

It says that if you don't define it in the generator.yml file, it is set to null


Leon
Re: Building Own Generator [message #37424 is a reply to message #37393 ] Mon, 15 October 2007 11:36 Go to previous messageGo to next message
DrCore  is currently offline DrCore
Messages: 59
Registered: August 2007
Member
May I suggest instead of using HTML code, to use Symfony helpers to include the JS and CSS files:

<?PHP
$Extjsdir = '/sfExtjsThemePlugin/';
sfContext::getInstance()->getResponse()->addJavascript($Extjsdir.'extjs/adapter/ext/ext-base');
sfContext::getInstance()->getResponse()->addJavascript($Extjsdir.'extjs/ext-all-debug');
sfContext::getInstance()->getResponse()->addJavascript($Extjsdir.'js/extGridGroupSummary');

sfContext::getInstance()->getResponse()->addStylesheet($Extjsdir.'extjs/resources/css/ext-all');
sfContext::getInstance()->getResponse()->addStylesheet($Extjsdir.'extjs/resources/css/xtheme-default');
sfContext::getInstance()->getResponse()->addStylesheet($Extjsdir.'css/symfony-extjs');
?>


This can also be done in the listSuccess.php template which would prevent loading the code even when it is not needed.

Cheers,
Andre
Re: Building Own Generator [message #37436 is a reply to message #24107 ] Mon, 15 October 2007 13:01 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
You can use the symfony helpers to include the css and js files, it depend on your needs.

If you use the symfony helpers, the includes are done in the head of your document, conforming the standards, and you won't include a file twice.

However you loose some control. I wanted the files to be included in my body, after I setup a div which says "Loading..." which includes an animated gif. If you do the includes before this, the loading-div would not have a lot of use...

[Updated on: Mon, 15 October 2007 13:02]


Leon
Re: Building Own Generator [message #37443 is a reply to message #24107 ] Mon, 15 October 2007 14:13 Go to previous messageGo to next message
Pete  is currently offline Pete
Messages: 5
Registered: October 2007
Junior Member
Thanks for your replies.

The group thing still exists - and i can't explain to myself why. I know the getParameter method and i know that the second parameter specifies the default value if it's not set in the request.
It should be null, at least. However, the workaround using the @ still works...

My problem is that i miss something essential - all my links open in a new window without <html> or <head> elements. Is the DHTML Layout also included in the plugin or do i have to create all my divs on my own? The "Add new ..." button doesnt work. Sorting doesn't work (clicking on the column headers).

Please tell me what i'm missing.


Thanks!
Re: Building Own Generator [message #37447 is a reply to message #37443 ] Mon, 15 October 2007 14:55 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
The layout.js isn't included in the library, and my idea was that this isn't necessarry for the basic functionality, but actually I haven't tested it without it.

If I have time I will build a sandbox tonight, I hope that would make things more clear and maybe some bugs will show up which I don't have at the moment.

the @-workaround is not an option, it should not be necessary, so my goal will be to fix this issue.

At the moment I am having problems with the Extjs Store. The Store provides access to data from the server (the JSON-data) and I want it to load 1 row after another. Normally you would use it to get a couple of rows at once, but when you have a large table, you want to use paging or get rows by their id.

This is possible, as long as you wait till you received the results from your previous request (the load command is theaded), otherwise your previous request gets cancelled. Unfortunately their is no way to wait till or see if your previous request is finished.

I am adding that functionality right now and am now capable of seeing when the load-request is done, so I can do my next request.


Leon
Re: Building Own Generator [message #37451 is a reply to message #24107 ] Mon, 15 October 2007 15:20 Go to previous messageGo to next message
Pete  is currently offline Pete
Messages: 5
Registered: October 2007
Junior Member
Will the layout.js create the necessary div's where the edit form and stuff is being displayed in?

Regards
Pete
Re: Building Own Generator [message #37454 is a reply to message #37451 ] Mon, 15 October 2007 15:48 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
Yes it does, but at the moment it is far to complex for a sandbox, that's why I will try to create sandbox tonight.

I will include a simple example with the data-model and generator.yml file.

But first I want to tackle my current problem. I figured out I want to add a queue to the store.load method, but implementing it is unfortunately cumbersome.


Leon
Re: Building Own Generator [message #37468 is a reply to message #24107 ] Mon, 15 October 2007 19:20 Go to previous messageGo to next message
ja@immune.dk  is currently offline ja@immune.dk
Messages: 3
Registered: October 2007
Location: Denmark
Junior Member
As Pete is mentioning there is an issue in the sfExtjsThemePlugin/generator/sfPropelAdmin/extjs/template/te mplates/_list_ajax_layout.php file.

In the cached version (javascript debug)
<b>Notice</b>: Undefined variable: group_field in <b>/Library/WebServer/Documents/sfproject/cache/frontend/dev/modules/autoAdmin_wiki/templates/_list_ajax_layout.php</b> on line <b>74</b><br />
197 sortInfo:{field: '<?= ?>', direction: "asc"}, 


And in the template, i guess its this one at line 173
$key = "<?= $group_field ?>"; 


And hey.. this looks danm great ~:)
Re: Building Own Generator [message #37470 is a reply to message #37468 ] Mon, 15 October 2007 20:12 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
OK OK Cool

I will write a howto of how to start with the standard symfony sandbox and how to add this extjs plugin to it. I will add a simple class to it, which I will show in a list.

I cannot post the result on this forum (size will exceed limits), but I will post the changes and addition I have to make to the default sandbox.

Also this should show any problems that there still are.


Leon
Re: Building Own Generator [message #37482 is a reply to message #37470 ] Tue, 16 October 2007 01:40 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 513
Registered: June 2007
Location: Netherlands
Faithful Member
I've created the howto, which guides you to the process of creating a master-detail view from the default symfony sandbox.

I did not bumped into the problem you people have described (can it maybe be due to a php.ini setting?), but I did try to change some code, so please do a svn update to check it out.



Quote:


Below the howto, it can also be found on the svn...




Setup the default symfony sandbox: (for the extjs part skip this part)

Start a new project (if you have symfony already installed) or download the sandbox from http://www.symfony-project.com/get/sf_sandbox.tgz
If you have downloaded the sandbox you can extract it in linux with "tar xvzf sf_sandbox.tgz", place the extracted folder in any map you like, for simplicity I place the entire content in my webfolder /var/www
Make sure your webserver has permission to write in the log and cache folder (chmod 777 /var/www/sf_sandbox/log; chmod 777 /var/www/sf_sandbox/cache)
You should now be able to browse to http://localhost/sf_sandbox/web/


Setup your database connection:

I prefer to use phpmyadmin, to add a user and database in MySql
- Add a new user
- Comeup with a username, host:localhost, password
- Choose to create a database as well: "Create database with same name and grant all privileges"
- Click Start

- In your project folder, setup config/database.yml:
all:
  propel:
    class:          sfPropelDatabase
    param:
      dsn:          mysql://username:password@localhost/username


And setup config/propel.ini: (don't be scared, it is almost default, only changed propel.project and database)
propel.targetPackage       = lib.model
propel.packageObjectModel  = true
propel.project             = sf_sandbox_extjs

propel.database            = mysql
propel.database.createUrl  = mysql://localhost/
propel.database.url        = mysql://username:password@localhost/username
propel.mysql.tableType     = InnoDB

propel.addGenericAccessors = true
propel.addGenericMutators  = true
propel.addTimeStamp        = false

propel.schema.validate     = false

; directories
propel.home                    = .
propel.output.dir              = /var/www/production/sfweb/symfony-for-release/sf_sandbox
propel.schema.dir              = ${propel.output.dir}/config
propel.conf.dir                = ${propel.output.dir}/config
propel.phpconf.dir             = ${propel.output.dir}/config
propel.sql.dir                 = ${propel.output.dir}/data/sql
propel.runtime.conf.file       = runtime-conf.xml
propel.php.dir                 = ${propel.output.dir}
propel.default.schema.basename = schema
propel.datadump.mapper.from    = *schema.xml
propel.datadump.mapper.to      = *data.xml

; builder settings
propel.builder.peer.class              = addon.propel.builder.SfPeerBuilder
propel.builder.object.class            = addon.propel.builder.SfObjectBuilder

propel.builder.objectstub.class        = addon.propel.builder.SfExtensionObjectBuilder
propel.builder.peerstub.class          = addon.propel.builder.SfExtensionPeerBuilder
propel.builder.objectmultiextend.class = addon.propel.builder.SfMultiExtendObjectBuilder
propel.builder.mapbuilder.class        = addon.propel.builder.SfMapBuilderBuilder
propel.builder.interface.class         = propel.engine.builder.om.php5.PHP5InterfaceBuilder
propel.builder.node.class              = propel.engine.builder.om.php5.PHP5NodeBuilder
propel.builder.nodepeer.class          = propel.engine.builder.om.php5.PHP5NodePeerBuilder
propel.builder.nodestub.class          = propel.engine.builder.om.php5.PHP5ExtensionNodeBuilder
propel.builder.nodepeerstub.class      = propel.engine.builder.om.php5.PHP5ExtensionNodePeerBuilder

propel.builder.addIncludes  = false
propel.builder.addComments  = false

propel.builder.addBehaviors = false



Setup a schema, in config/schema.yml, I shall define a master-detail relationship
propel:
  assignment:
    id:
    name:               {type: varchar(255), required: true}

  parcel:
    id:
    assignment_id:
    name:               {type: varchar(255), required: true}


run "symfony propel-build-all" to generate the model and create the tables in your database
TIP: if you are running linux, look for the bash completion script, and place it in /etc/bash_completion.d if you now (again) login into a terminal, you have symfony arguments completion. So type "symfony <tab><tab>" and enjoy!


Create the modules:
symfony propel-init-admin frontend assignment Assignment
symfony propel-init-admin frontend parcel Parcel

That's it, you should now be able to visit
http://localhost/sf_sandbox/web/frontend_dev.php/assignment
and
http://localhost/sf_sandbox/web/frontend_dev.php/parcel

Because at the moment my plugin cannot edit, nor save items, it is wise to add some assignments, and parcels.
I created assignment1, assignment2, assignment3 and parcel1a, parcel3a, parcel3b and parcel3c


----------------

OK, this should all have been great (don't forget how cool symfony is Wink ), but familiar.

Time for the Extjs part:

For now, you have to do a svn checkout to add the plugin to your project,
go to your plugin folder and type:
svn co http://svn.symfony-project.com/plugins/sfExtjsThemePlugin/
Or use a gui tool like rapidsvn, tortoise, subclipse, what ever makes you happy

Copy the content of the sf_sandbox/plugin/sfExtjsThemePlugin/web folder to your sf_sandbox/web/sfExtjsThemePlugin folder, or in linux, make a symlink:
cd sf_sandbox/web; ln -s ../plugins/sfExtjsThemePlugin/web/ sfExtjsThemePlugin


Include the javascript and stylesheets, add the following code to your applications layout.php file:
<?php
$Extjsdir = '/sf_sandbox/web/sfExtjsThemePlugin/';
sfContext::getInstance()->getResponse()->addJavascript($Extjsdir.'extjs/adapter/ext/ext-base');
sfContext::getInstance()->getResponse()->addJavascript($Extjsdir.'extjs/ext-all-debug');
sfContext::getInstance()->getResponse()->addJavascript($Extjsdir.'js/extGridGroupSummary');

sfContext::getInstance()->getResponse()->addStylesheet($Extjsdir.'extjs/resources/css/ext-all');
sfContext::getInstance()->getResponse()->addStylesheet($Extjsdir.'extjs/resources/css/xtheme-default');
sfContext::getInstance()->getResponse()->addStylesheet($Extjsdir.'css/docs');
sfContext::getInstance()->getResponse()->addStylesheet($Extjsdir.'css/symfony-extjs');

?>


Now go to your the generator of your module, for example the one from assignment and change the theme from default to extjs.

If you now browse to http://localhost/sf_sandbox/web/frontend_dev.php/assignment you should see a list of assignments (with their id) in the Extjs theme

(Hmmm. For some reason I don't seem to have all css properties. The Add-new button is a square, also the pager buttons look strange, and the column-headers seem to mis a background image, until you hover over them. I haven't firgured out what causes this, yet.)
(Hmmm2, I don't get the errors you people seem to have about group_field not being defined. Can it be a php.ini setting? I think I can add some code to prevent the error, but I can't test it as it does not happen to me...)


Now to make things more interesting, lets make a master detail, change the generator.yml file from assignment to this:
generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      Assignment
    theme:            extjs

    sub_class:
      model_class:    Parcel
      join_field:     assignment_id
      display:        [name]
      fields:
        name:
          name:       Parcel-Name

    list:
      display:        [name]

I did find one bug. Unfortunately currently I haven't figured out how to automatically resolve the foreign-key-field between two tables, so you have to define the foreign-key-field yourself (I named it join_field). In my situation it went good, because of some lucky field-naming.

Reload http://localhost/sf_sandbox/web/frontend_dev.php/assignment to see the results. (you won't have to ClearCache when you have changed the generator.yml file in this case)

You can click on the header: "parcel-name" to change the sort order within every assignment (click it twice to sort descending)
You can click on a parcel-name field, to change it name. (Saving the changes still have to be implemented)

In the generator.yml file, place a '=' before the diplay name under the sub_class, to make the field a hyperlink to the sub_class edit page. (display: [=name])

To give an other example I will use the parcel class.

First add the folowing code to the lib/model/Assignment.php file:
class Assignment extends BaseAssignment
{
  public function __toString()
  {
    return $this->getName();
  }
}


Change the generator.yml file of parcel to:
generator:
  class:              sfPropel