This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » Building Own Generator  (4) 7 Vote(s)
Re: Building Own Generator [message #50270 is a reply to message #50240 ] Fri, 18 April 2008 13:30 Go to previous messageGo to next message
KRavEN  is currently offline KRavEN
Messages: 213
Registered: May 2007
Faithful Member
lvanderree wrote on Thu, 17 April 2008 18:49

My idea about the dynamic loading of scripts is like this:

imaging you have a list (grid) of cities, and you want to add a city. I will write down the pseudo-javascript/actions for it.

Click add-city button from toolbar
- javascript checks if var CityEditor has been defined
  - if not defined, load module City action Create.pjs (as seen in http://blogs.byte-force.com/xor/archive/2008/04/16/1758.aspx )
  - this would load the layout-only 
    - now the layout is loaded and set in the var CityEditor a callback function will perform the rendering of the CityEditor-Panel (just like is done in http://backoffice.kaffill.de/ext2/ext2 when pressing the window button )


When we want to save this new city, we click the save button (delete should not be there for a new object)
Click Save
- save the form
  - A callback function will set the key (which this new item gets and returns in the succes:json-result) for this form/panel/window
  = the delete button should now appear


When we now also want to edit a item from the (same) list, we click on one of the items
Click on a item
- Check if var CityEditor has been defined (which now is, because of the clicking on add city from before, and since action create and action edit should return the same layout (except for the delete-button somehow) this is fine)
  - Open a new windows/panel with this layout (see kaffill again)
    - get the content with a query and load the json-data.


hardcoding the ids of the panels/forms/windows should be obsolete I think, you can find elements by querying them on properties.

This would be ideal I think, but requires significant rewriting of current code and I haven't got an idea about how to make a difference between create and edit (with the delete button). This difference should be made client-sided, by checking for example if the PrimaryKey is set as some property, but no idea how to write this javascript yet, since everything is defined by javascript-config style.


Please tell me what you people think about this.

I implemented something similar when I added the upload panel action.

Check out ajaxUploadJsSuccess.pjs and ajaxUploadSuccess.php along with the executeAjaxUpload** actions. The action is defined in the upload case in the getAjaxButtonToToolbarAction method.

I use the same sort of method whenever I have a tabpanel to load the content for the tabs.
Re: Building Own Generator [message #50278 is a reply to message #50268 ] Fri, 18 April 2008 14:07 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
Thanks for your help Leon. i've tried and it didn't work i have still the javascript error and no list display Sad

apparently,The problem is here :

plugins: new Ext.ux.TabCloseMenu(),


TabCloseMenu() seems to be undefined Sad

[Updated on: Fri, 18 April 2008 14:07]

Re: Building Own Generator [message #50279 is a reply to message #24107 ] Fri, 18 April 2008 14:13 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
Yesssss it's workingggg Shocked

thank you very much Leon. In fact i had clear cache with firefox only the first time. with command line symfony cc it's working .

thanks.i'll do a little test and after i'ill post here the code source for updating the howtosandbox if you want.

thanks a lot i'm very happy Smile
Re: Building Own Generator [message #50283 is a reply to message #50279 ] Fri, 18 April 2008 14:40 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Haha, great, Didn't thought about clearing firefox cache, but good to hear you found out it was supposed to be symfony cache Wink

I like to hear all your findings, so a new sandbox/howto would be great, but also bug-reports, or improvements are more than welcome!

The more people will use this plugin, the better it can get...


Leon
Re: Building Own Generator [message #50288 is a reply to message #50270 ] Fri, 18 April 2008 14:56 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Hi KRavEN,

this indeed looks like the thing I described for the edit-panels.

I am investigating it

Ps. you set urls like this:
url: '<?php echo $this->getModuleName() ?>/ajaxUploadReceive',

but I think it is better to use the controller to resolve the urls, like:
<?php $controller = sfContext::getInstance()->getController(); ?>

...

url: '<?php echo $controller->genUrl($this->getModuleName().'/ajaxUploadReceive') ?>',


See svn update Wink

[Updated on: Fri, 18 April 2008 15:04]


Leon
Re: Building Own Generator [message #50289 is a reply to message #24107 ] Fri, 18 April 2008 15:03 Go to previous messageGo to next message
KRavEN  is currently offline KRavEN
Messages: 213
Registered: May 2007
Faithful Member
Yeah, you're right. I'll update and checkin the change.

On a side note, do you know why using multiple separator's in the action isn't working?

For instance, an action config like so:

      actions:
        _upload:        -
        _separator:     -
        _delete:        -
        _separator:     -
        _import:        -
          name:               Import
          class:              btn_session_add
        _separator:     -
        _fill:          -
        _print:         -


I only see the first separator.
Re: Building Own Generator [message #50291 is a reply to message #50289 ] Fri, 18 April 2008 15:10 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I guess it is probably because I use a associative array somewhere, and since the names of the seperators are the same, only one will remain...

Had this same issue with fields, and resolved it by using a normal array. I will take a look at it later on.

Is everything still working for you, after I changed the edit-pages, and submit-buttons?

I am really thinking about rewriting the edit-pages even further, so they are implemented as described in the previous posts. This will probably will introduce new problems, but hopefully solve more of them Wink

I think there should also be an event-manager introduced, on which lists can announce themselves, and to which edit-pages can tell they have just saved/deleted an item (so the lists who are subscribed for that item-type can automatically reload themselves). We now both use hardcoded moduleList.getDataStore.reload(), but imagine you have list of cities (with the county they are in) and you fix a typo in the naming of a country, you want the city-list to be reloaded, so the naming of the countries gets fixed... (there are of course more examples of where this works)


Leon
Re: Building Own Generator [message #50296 is a reply to message #50291 ] Fri, 18 April 2008 15:53 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I did some debugging regarding the missing separators from list.actions and it turns out it is due to symfony's getParameterValue method (see _list_ajax_actions.php).



I retraced it till
generator/sfAdminGenerator.class.php.sfAdminGenerator->getValueFromKey : lineno 458	
	generator/sfAdminGenerator.class.php.sfAdminGenerator->getParameterValue : lineno 410	
	plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_list_ajax_actions.php.require : lineno 2	
	generator/sfGenerator.class.php.sfGenerator->evalTemplate : lineno 96	
	generator/sfGenerator.class.php.sfGenerator->generatePhpFiles : lineno 66	
	config/sfGeneratorConfigHandler.class.php.sfGeneratorConfigHandler->execute : lineno 72	
	config/sfConfigCache.class.php.sfConfigCache->callHandler : lineno 103	
	config/sfConfigCache.class.php.sfConfigCache->checkConfig : lineno 190	
	config/sfConfigCache.class.php.sfConfigCache->import : lineno 248	
	controller/sfController.class.php.sfController->forward : lineno 194	
	controller/sfFrontWebController.class.php.sfFrontWebController->dispatch : lineno 48	
	web/backend_dev.php.{main} : lineno 10	
	controller/sfFrontWebController.class.php.sfFrontWebController->dispatch : lineno 48	
	web/backend_dev.php.{main} : lineno 10	


$ref   =& $this->params;

on line 458 of sfAdminGenerator.class.php which holds the params from your generator.yml, and at this time it already lost the second separator.


Leon
Re: Building Own Generator [message #50298 is a reply to message #24107 ] Fri, 18 April 2008 16:00 Go to previous messageGo to next message
KRavEN  is currently offline KRavEN
Messages: 213
Registered: May 2007
Faithful Member
Everything seems to be working for me thus far, but I don't use the edit features. Most of the time if I need to edit a record, and it can't be done inline in the grid, it needs to be too customized to use a generated form.

I just checked in some changes I made to the _list_layout so it's easier to add new methods. I also made some changes to the grid row doubleclick listener methods and templates.
Re: Building Own Generator [message #50299 is a reply to message #50298 ] Fri, 18 April 2008 16:21 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member

I continued to search for the problem with multiple separators, but I think it will be difficult to tackle.

I retraced it all the way back to:
	config/sfYamlConfigHandler.class.php.sfYamlConfigHandler->parseYamls : lineno 37	
	config/sfGeneratorConfigHandler.class.php.sfGeneratorConfigHandler->execute : lineno 35	
	config/sfConfigCache.class.php.sfConfigCache->callHandler : lineno 103	
	config/sfConfigCache.class.php.sfConfigCache->checkConfig : lineno 190	
	config/sfConfigCache.class.php.sfConfigCache->import : lineno 248	
	controller/sfFrontWebController.class.php.sfFrontWebController->dispatch : lineno 48	
	web/backend_dev.php.{main} : lineno 10	
	web/backend_dev.php.{main} : lineno 10	


which says:
$config = sfToolkit::arrayDeepMerge($config, $this->parseYaml($configFile));

And already at this point (parsing the yml file) things go wrong and the duplicates get removed.

My idea to get passed this, is by give the separators different namings, like _separatorIDONTCAREWHAT1. _separatorSOMETHINGELSE2, ETC

And while parsing only check for _seperator which will tell enough...

About the edit pages:
I am trying to implement enough hooks in the edit-pages, to make it possible to override just the parts you want


Leon
Re: Building Own Generator [message #50304 is a reply to message #50298 ] Fri, 18 April 2008 16:33 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
Hi all,

I know it's not a lot of work but i put some code to update the HowTo Sandbox

now it display parcel and assignment correctly Smile


Assignment generator :

generator:
  class:              sfExtjsPropelAdminGenerator
  param:
    model_class:      Assignment
    theme:            extjs
  
    list:
      display:        [name]
      actions:
       _create:
          name: Add new Assignment
       _refresh: -
       _print: -
       _pdf: -

Parcel Generator
generator:
  class:              sfExtjsPropelAdminGenerator
  param:
    model_class:      Parcel
    theme:            extjs
   
    field:
      name:
         params:
          editable: true  
		
    list:
      display:        [=id, assignment_id/name , name]
 


Now i have to work on handler Smile

I hope this will help beginner like me.

[Updated on: Fri, 18 April 2008 17:34]

Re: Building Own Generator [message #50308 is a reply to message #50304 ] Fri, 18 April 2008 16:52 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Thanks I will update it in the wiki/svn soon.

Maybe it isn't much work, but is hard for me to keep updating them all the time, so great work!

and if you have other problems or remarks, please say so Wink


Leon
Re: Building Own Generator [message #50309 is a reply to message #50308 ] Fri, 18 April 2008 16:56 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Ps. I can be mistaking, but I think the 'sub-class' part is obsolete, isn't it?

Can you remove it, without loosing functionality?


Leon
Re: Building Own Generator [message #50311 is a reply to message #50309 ] Fri, 18 April 2008 16:59 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
And question2 about the sandbox howto:

you should be able to change assignment_id to assignment_id/name for the parcel-list.display. Isn't that nicer to show the capabilities?


Leon
Re: Building Own Generator [message #50312 is a reply to message #50309 ] Fri, 18 April 2008 17:00 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
yes sorry i didn't see it.Without it works fine. i'll update my previous post

for question2: The parcel list display now the name of assignment and not the id. (i'm not sure it's what's you were talking about?)

[Updated on: Fri, 18 April 2008 17:37]

Re: Building Own Generator [message #50320 is a reply to message #50312 ] Fri, 18 April 2008 18:26 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
about question2, yep that is exactly what I meant. This is some functionality which I've added (based on the work of DrCore) which I think is pretty nice... It even works recursively Surprised


Leon
Re: Building Own Generator [message #50428 is a reply to message #24107 ] Sun, 20 April 2008 23:44 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I was making great progress this weekend, with generating config-javascripts for edit-pages!

This way you only have to load a layout only once (on the fly, so when needed) and after that you can create many instances of it in runtime (only requiring to load the json-data to fill the edit-page with content).

However I encountered a bug, probably related to extjs, which slows down my progress. See http://extjs.com/forum/showthread.php?t=33070

I'm thinking about committing before datastores/readers are connected the the edit-forms... So maybe more people can help implementing Wink

But first all forms have to be created completely. (and hopefully this bug is solved before that)

[Updated on: Sun, 20 April 2008 23:45]


Leon
Re: Building Own Generator [message #50487 is a reply to message #50428 ] Mon, 21 April 2008 13:59 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I think I am currently rewritting the generator for the edit-pages for the 4th time (in total) but things now get really nice, if I may say so Wink

the php-generator-script now creates php-templates containing sfExtJs2Plugin-scripts, which have enough includes to define hooks to override a lot of parts. These templates create extjs-javascript in pjs files which gets included/loaded in your page when first requested Surprised

lots of things to do, but at least I am really happy with it Surprised


Leon
Re: Building Own Generator [message #50590 is a reply to message #24107 ] Tue, 22 April 2008 14:19 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
hi leon.
I have an other question Confused

I'm wondering if it is possible to put only a grid in a panel with the plugin like this http://fun4me.demon.nl/test/test_dev.php/city .
In fact , i have a grid in a combobox in a panel and i would like to have only a grid in a panel.

thanks Smile

clad
Re: Building Own Generator [message #50628 is a reply to message #50590 ] Tue, 22 April 2008 17:26 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Hi Clad. I am afraid I don't understand you completely.

putting a grid to a panel is possible (just like edit-panels in a tabpanel), as you can see (fun4me is my site). However it might require some changes in E.G. your layout.php file, or setting some config files.

I think tejohnston.dynora.eu shows the best example of what is possible at the moment with edit-page in tabpanels and lists (grids) in (tab)panels.

In fact everything is possible, but sometimes it requires some changes in the layout.php file, sometimes a configuration has to be set, and sometimes maybe something have to be added to the generator to make more things possible.

At the moment I am working on the reimplementation of the edit-pages, and this gets realy nice, using configurations to define panels, so you can load them as new items in existing panels.

I completely lost you when you said you hava a grid in a combobox :S

maybe if you define your specific problem more clearly I can tell how you can accomplish things...


Leon
Re: Building Own Generator [message #50633 is a reply to message #50628 ] Tue, 22 April 2008 17:54 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
Sorry if i'm not clear.In fact i think i make a lot of confusion between sfExtjs2Plugin and sfExtjsTheme plugin. I don't know how using both correctly.For example. I know how create a grid with sfExtjsThemePlugin but not with sfExtjs2Plugin .

I know http://fun4me.demon.nl/test/test_dev.php/city is your website and it is pretty cool. It is precisely what i try to do.You have a panel and in the panel(not a tabpanel) a grid.

In fact in my layout i have :




<body>
<div id="content">
<?php echo $sf_data->getRaw('sf_content') ?>

</div>
<div id="content2">test</div>
<div id="content3"></div>

<?php 



 $sfExtjs2Plugin = new sfExtjs2Plugin(array('theme'=>'gray'));
  $sfExtjs2Plugin->load();
  $sfExtjs2Plugin->begin();

$sfExtjs2Plugin_App_viewport = $sfExtjs2Plugin->Viewport(array
(
  'layout' => 'border',
  'items'  => array
  (
  
     $sfExtjs2Plugin->Panel(array
    (
      'region' => 'west', 
      'border' => true,
      'title' => 'menu',
      'width' => 200,
      'collapsible'  => true, 
      'collapseMode' => 'mini', 
      'split'        => true
	
	     
	     
	  
   )),
   

    $sfExtjs2Plugin->Panel(array
    (
      'region' => 'center',
      'border' => true,
      'plain'  => true,
      'collapsible'  => true, 
  
      //'layout' => 'fit',
	  
	  'items' => array(
              $sfExtjs2Plugin->Panel(array(
                'region' => 'center',
                'title' => 'Content',
                'contentEl' => 'content',
                'titleCollapse' => true,
                'collapsible'  => true,
               'collapseMode' => 'mini', 
                'autoScroll' => true
              )),
              $sfExtjs2Plugin->Panel(array(
                'region' => 'center',
                'title' => 'Content2',
        		 'contentEl' => 'content2',
               'collapsible'  => true,
                'autoScroll' => true
              )),	   	   
  			        $sfExtjs2Plugin->Panel(array(
		                'region' => 'center',
		                'title' => 'Content3',
		        		'contentEl' => 'content3',
		                'collapsible'  => true,
		                'autoScroll' => true,
		              	'items' => array(  	   
		               $sfExtjs2Plugin->TabPanel(array(
		                'region' => 'south',
		                'title' => 'info',
		                'titleCollapse' => true,
		                'items' => array(
		                  $sfExtjs2Plugin->Panel(array(
		                    'contentEl' => 'Onglet 1',
		                    'title' => 'Onglet 1',
		                    'autoScroll' => true
		                  )),
		                  $sfExtjs2Plugin->Panel(array(
		                    'contentEl' => 'Onglet 2',
		                    'title' => 'Onglet 2',
		                    'autoScroll' => true
		                  )),
		                  $sfExtjs2Plugin->Panel(array(
		                    'title' => 'Onglet 3',
		                    'contentEl' => 'Onglet 3',
		                    'autoScroll' => true
		                  ))
		                )
		              ))
		             ) 
		         ))     
    	)
	 
	     
	     
	  
   ))
  )
	
		 
));  
  
$sfExtjs2Plugin->beginApplication(array
(
  'name'   => 'App',
  'public' => array
  (
    'init' => $sfExtjs2Plugin->asMethod(
    "
        Ext.QuickTips.init();
          $sfExtjs2Plugin_App_viewport;
        ") 
  ) 
));
 
$sfExtjs2Plugin->endApplication();
$sfExtjs2Plugin->end('Ext.onReady(App.init, App);');


?>



</body>


But in content div , i Have a grid but there are a border with the title defined in my parcel generator list for exemple. i put the title to false and i have always the border (the border seems to be like border in combobox). i don't want to see this border.

In your website there is no border...Perahps it's simply a problem in my CSS ...

I have a lot of anothers questions about this very interressant plugin.In fact i have read all doc but with all changes, i'm not sure about what we can really do with it.

thanks a lot leon Smile
Re: Building Own Generator [message #50670 is a reply to message #24107 ] Wed, 23 April 2008 10:51 Go to previous messageGo to next message
IsRobot  is currently offline IsRobot
Messages: 83
Registered: March 2008
Location: East Midlands, UK
Member
ExtJS 2.1 has been released - will the sfExtJS2Plugin and sfExtjsThemePlugin be updated in line with this release do you think?


web development
Re: Building Own Generator [message #50677 is a reply to message #50670 ] Wed, 23 April 2008 13:46 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I had already upgraded the sfExtjs2Plugin to Ext2.1 earlier this week, so if you do an svn-update you should have the new Extjs2.1 Please be aware of the changed license of Extjs2.1 (changed from lgpl to GPLv3: http://www.extjs.com/products/license.php )

About the differences between sfExtjs2Plugin and sfExtjsThemePlugin.

sfExtjs2Plugin: is the wrapper-plugin arround ExtJS 2(.1) You can write php which results in extjs-javascript code. The idea behind it is that you don't have to change your php-code if you want to use another javascript-library, you simply can replace it with an other wrapper. (although I don't know how this will work-out since all arguments in the php-code are specific to the extjs api...)

the sfExtjsThemePlugin is a theme/generator for symfony which replaces the default static html (with tables for lists and forms for edit-pages) which is generate by the default symfony-generator by extjs-powered html/js-scripts using extjs. So grids and extjs-forms with their datastores are setup to present you your data.
The sfExtjsThemePlugin depends on the the sfExtjs2Plugin for generating the extjs-javascript code.

In my new version of the sfExtjsThemePlugin, which I will commit soon, I will make more use of the sfExtjs2Plugin. The sfExtjs2Plugin uses arrays as an argument, but in contradiction to most javascript-engines, php has no problem with extra comma's in you array-content, which makes things easier to read in the generator.

I've also choosen to let the php-generator script generate php-template-scripts which contain the calls to the sfExtjs2Plugin. This means that at run-time when a person browses your application, the php-templates call the sfExtjs2Plugin-functions to generate javascript. I could already do this during generation, but this would make it harder to change and override the templates by/with custom php-code.

THe only thing I want to implement before committing is the implementation of showing the new edit-panels (when you click the add-button or on a link of one of your items in the grid).
What will not be implemented yet is the connection to the datastores. So your edit-pages will for the moment stay empty and cannot store anything either. So if you want to keep editing and your items, you should not update the sfExtjsTheme plugin, if you want to help me you can update and test/expand the new code. The old version will be obsolete, it was compatible with Extjs1.0 (someday) and now everything will be written in the much nicer way of extjs2 which is extendible and is only required to be loaded once (instead of for every item you want to edit you had to load the complete layout).


Leon
Re: Building Own Generator [message #50679 is a reply to message #50677 ] Wed, 23 April 2008 14:17 Go to previous messageGo to next message
IsRobot  is currently offline IsRobot
Messages: 83
Registered: March 2008
Location: East Midlands, UK
Member
Hi Leon,

thanks for the update and the overview of the two plugins. It has helped me understand them a little better Smile


web development
Re: Building Own Generator [message #50709 is a reply to message #50679 ] Thu, 24 April 2008 03:18 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
OK People,

it has been done! I have committed.
Before updating your svn, please be-aware that this will brake functionality!

TODO's:
- setup datastore/datareaders to make loading/saving of form-content possible
= setting PK in form-field
- Add ability to set some fields with predefined values.
- clean-up old code & old php-files (I improved naming)

I changed default settings, so more things should work out of the box. (this is especially for KRavEN, if these settings don't work for you it probably is best to overrule them in your application, but maybe I set some silly defaults, in that case please tell me of course)

For a Live demo of current capabilities, please check: http://fun4me.demon.nl/test/test_dev.php

Things you can test: click on Add City (add country does not work yet, since I don't set the correct url to load yet)
Click on an existing city (will not show the city, but it does load).

The code of these edit-pages is much much cleaner. Extjs2-style and best of all: The layout is now lazy loaded (only once and only when you need it). I do it differently than you KRavEN, not with an head where I include the javascript, but with a library which can lazy load Surprised) So only the first time you want to see an edit-page it will be somewhat slower, after that it will be fast.

The sfExtjsTheme plugin now depends on another plugin: sfPJSPlugin (which you should install yourself). This plugin adds the ability to return prue javascript files (with a javascript header).

I tried to made the generated-code for the templates to be mostly php (so not javascript), which should make it easier to override/extend it per template.

I included the source of the demo (which should work almost out of the box, just set your database/propel settings and include sfExtjsTheme and sfExtjs2 plugins). Most important things are the layout.php file of the application and the setup of the pjs-plugin.

There is probably a lot I did not mention yet, but it is time for bed right now

  • Attachment: test.zip
    (Size: 155.83KB, Downloaded 152 time(s))


Leon
Re: Building Own Generator [message #50714 is a reply to message #24107 ] Thu, 24 April 2008 05:17 Go to previous messageGo to next message
saganxis  is currently offline saganxis
Messages: 24
Registered: February 2008
Location: Argentina
Junior Member
Hi this is my fisrt time with this plugin. I downloaded and i've created an admin-backend. It wokrs fine with the list in a grid. But when i try to create a new one the firebug tell me there is an error and nothing happens. It tells me

using.registered has no properties
using.js line 28


I don't know which is the problem, any help????
Re: Building Own Generator [message #50738 is a reply to message #50714 ] Thu, 24 April 2008 10:58 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Hi saganxis,

this problem is because you have to initialise the using-script.

You can simply do this by calling using.register(); without arguments. I did this in the layout.php file which is not included in the plugin like this:
<script type="text/javascript">
  using.register(); 
</script>


BUT when you do a svn-updatre I've committed a fix for this which does the initialisation in the theme Surprised


Leon
Re: Building Own Generator [message #50740 is a reply to message #50738 ] Thu, 24 April 2008 11:19 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
Hi all,

the update looking good.

But i have also javascript error in firebug and i have no grid display:

my errors:

Ext.ux.TabCloseMenu is not a constructor (like the last time ???) (city line 674)

using is not defined (city line 144)

using is not defined (city line 115)

I think i installed sfPJS plugin correclty.

Any idea about what i'm doing wrong?

thanks

[Updated on: Thu, 24 April 2008 11:26]

Re: Building Own Generator [message #50749 is a reply to message #50740 ] Thu, 24 April 2008 13:27 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Hi clad,

I think your problems are caused by your layout.php file.
You probably call $sfExtjs2Plugin->load() there, which overrides the $sfExtjs2Plugin->load() call from the listAjaxSucces.php file (which loads all required javascripts)

You can probably fix this by removing $sfExtjs2Plugin->load() from your layout.php file OR add the following lines to your layout.php file in the header
<?php
$Extjsdir = '/sfExtjsThemePlugin/';

sfContext::getInstance()->getResponse()->addJavascript($Extjsdir.'js/extTabCloseMenu');
sfContext::getInstance()->getResponse()->addJavascript($Extjsdir.'js/using/using');
?>


Leon
Re: Building Own Generator [message #50754 is a reply to message #50749 ] Thu, 24 April 2008 14:08 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
lvanderree wrote on Thu, 24 April 2008 13:27

Hi clad,

I think your problems are caused by your layout.php file.
You probably call $sfExtjs2Plugin->load() there, which overrides the $sfExtjs2Plugin->load() call from the listAjaxSucces.php file (which loads all required javascripts)

You can probably fix this by removing $sfExtjs2Plugin->load() from your layout.php file OR add the following lines to your layout.php file in the header
<?php
$Extjsdir = '/sfExtjsThemePlugin/';

sfContext::getInstance()->getResponse()->addJavascript($Extjsdir.'js/extTabCloseMenu');
sfContext::getInstance()->getResponse()->addJavascript($Extjsdir.'js/using/using');
?>



Thanks for your reply but i have the same layout.php and it doesn't work.

I' ve try to remove the load but it doesn't work too Sad

[Updated on: Thu, 24 April 2008 14:12]

Re: Building Own Generator [message #50757 is a reply to message #50754 ] Thu, 24 April 2008 14:26 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Is your sfExtjsThemePlugin/web-folder linked(or copied) to your projects-web-folder, so it is accessible by your browser? So can you go to: http://fun4me.demon.nl/test/sfExtjsThemePlugin/js (where fun4me.demon.nl/test is the url of your webserver/project


Leon
Re: Building Own Generator [message #50759 is a reply to message #50757 ] Thu, 24 April 2008 14:43 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
lvanderree wrote on Thu, 24 April 2008 14:26

Is your sfExtjsThemePlugin/web-folder linked(or copied) to your projects-web-folder, so it is accessible by your browser? So can you go to: http://fun4me.demon.nl/test/sfExtjsThemePlugin/js (where fun4me.demon.nl/test is the url of your webserver/project




Thanks that's was it. i had the wrong url.I had /sfExtjsThemePlugin/web/js instead of /sfExtjsThemePlugin/js.

In your example you have a border with the title "city list".I know that we can change the title in generator file but i'm wondering if it is possible to have only the grid and not this border?(we can put the title to default to have no title but there are still the border).

And last question, can we move the toolbar in wich there are action (like create,print) to put it in an other location in the page ?

[Updated on: Thu, 24 April 2008 14:44]

Re: Building Own Generator [message #50763 is a reply to message #50759 ] Thu, 24 April 2008 15:02 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Yes you can switch of the border,

but because everything is work in progress, and because you probably have tons of more questions wants you are up-and-running, it might be better not to give you the direct-answer, but show you how you can find out.

Everything the generator creates is described in the php-generator-scripts (which generated php-templates, which result in html/javascript). These php-generator-scripts can be found at the sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/templa te/templates folder. You start with the files without an underscore in front of them (so most importantly listAjaxSucess.php and editAjaxSuccess.php) these files include all kind of templates (which start with an underscore) (there are also some files with double underscores (__) these are special php-generator-templates which are recursively included or exported to different file-names.

All files which we use for the Extjs-Theme should have the following naming <action>AjaxSuccess.php or for templates <action>_ajax_<description>.php

Now when you want to find out where the border is defined, you know it is about grids, so you look at the listAjaxSucess.php file And somewhere near the bottom you see
<?php if ($this->getParameterValue('border_panel', sfConfig::get('app_sf_extjs_theme_plugin_border_panel', true))): ?>

which says if in the generator.yml file border_panel is set as a parameter, look at its value, else use as default value the result of the app.yml-config file (preferably you define this in your application, and do not override the app.yml file of the plugin, but you can take a look at it as an example) and look if all:sf_extjs_theme_plugin:border_panel is set, else use as default true.

so what you probably want is set in your application, the following app.yml-file in its config folder:
all:
  sf_extjs_theme_plugin:
    border_panel: false


I don't know where you want to place the toolbar, but now you know that you can take a look at _list_ajax_layout.php (use a file-search if you don't know where to start looking, and look for toolbar) and look if you can find a way to change the location of the toolbar.
Now you can look for a way to add make it better configurable (by adding new config-options) so it can be included by a patch to the plugin, or if you have an exception which will only show up once, overrule the generated template by copying it from the cache and place it in your module/template folder and alter it overthere.

I hope I made some sense and if you could make a/update the howto for other people from this, please post it.


Leon
Re: Building Own Generator [message #50767 is a reply to message #50763 ] Thu, 24 April 2008 15:24 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
thanks it work. i had already seen the plugin file ( not in detail)
but it's not easy for beginner, there are a lot of information .

i'll try to update some part of howTosandbox in the future to give more information because it's very difficult at the begining.

thanks for your help Leon

clad
Re: Building Own Generator [message #50771 is a reply to message #24107 ] Thu, 24 April 2008 15:53 Go to previous messageGo to next message
saganxis  is currently offline saganxis
Messages: 24
Registered: February 2008
Location: Argentina
Junior Member
Wow hay fast reply!!! thanks a lot lvanderree!! Surprised
I added the scipt

<script type="text/javascript">
  using.register(); 
</script> 


but i have other error... Sad
It says

tipo_alojamiento (line 322)
using.js (line 91)

Ext.app.sx has no properties
(no name)()
using("url(/backend_dev.php/js/tipo_alojamiento/editAjaxJs.pjs)", function(), undefined)
addTab("Add new TipoAlojamiento", "/backend_dev.php/tipo_alojamiento/create", "create_TipoAlojamiento", Object, "icon-edit", true, true)

handler()


I'm not sure what i'm doing wrong. I downloaded the plugin yesterday from the svn. Then make the simboliks link.
I 'd appreciate any help.
Re: Building Own Generator [message #50772 is a reply to message #50771 ] Thu, 24 April 2008 16:07 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
At the moment it does not automatically load all required pjs scripts.

Can it be that you in one module (for examples cities)
and try to show an edit-page from another module (for example countries).

When you look at the live demo: http://fun4me.demon.nl/test/test_dev.php I think you get the same error when you press the 'add country' button, because you are in a city-list and it does not (yet) auto-load the country.pjs-file


Leon
Re: Building Own Generator [message #50787 is a reply to message #50772 ] Thu, 24 April 2008 18:40 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I cleaned up the files in the generator-template-folder somewhat, this might make it somewhat easier to find your way in the files.

Current todo:
I am going to re-implement the edit-stores/readers

Long-term todo, rewrite the lists to make the code look more like how it is done in the edit-pages.

How do the other guru's like the new implementation of the edit-pages? I think you KRavEN can also use similar methodes I used, and maybe we together can improve them even further.

At the moment I am very happy with the lazy-loading, which is possible because of the using.js script and the pjs-plugin. And I am very happy with the generated script ( http://fun4me.demon.nl/test/test_dev.php/js/city/editAjaxJs. pjs ); which creates a new panel-object and registers it as a new xtype-object. (this is what I want to accomplish as well for the list-pages for the long-term).


Leon
Re: Building Own Generator [message #50820 is a reply to message #50787 ] Fri, 25 April 2008 10:10 Go to previous messageGo to next message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
Hi all,
Yesterday Plugin was working correctly.
Today when i load pages of test code i have a symfony exception.
Sort column "partial" not found
stack trace

    * at ()
      in  SF_ROOT_DIR\cache\test\dev\modules\autoCity\actions\actions. class.php line 660 ...
             657.
             658.         if (!$found)
             659.         {
             660.           throw new Exception('Sort column "'.$sort_column.'" not found');
             661.         }
             662.
             663.         try



I saw in this thread that in the past, there was the same problem but i don't find a solution.

Does Anyone have the same problem ?
I put in comment line

  if (!$found)
        {
          throw new Exception('Sort column "'.$sort_column.'" not found');
        }
and it work until i clear cache. Is it a bug of generator or am i doing something wrong?
Thanks

[Updated on: Fri, 25 April 2008 10:49]

Re: Building Own Generator [message #50824 is a reply to message #50820 ] Fri, 25 April 2008 10:58 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Problems with sorting can often be solved by removing your browser-cookies (for the symfony session),

if you can reproduce it afterwards we have to find out why your app want to sort on the partial column


Leon
Re: Building Own Generator [message #50825 is a reply to message #50824 ] Fri, 25 April 2008 11:05 Go to previous messageGo to previous message
clad  is currently offline clad
Messages: 23
Registered: April 2008
Junior Member
thanks i removed cookies and it's work. but i don't understand what's happening .
Previous Topic:i18n form question
Next Topic:German symfony workshops/trainings
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software