| 101 | | Now we are ready to go. If you try http://servername/app_dev.php/mod/report it should open the PDF document. PDF is the default format but you can change to any format supported by !OpenOffice.org in the view class (explained later). |
|---|
| | 101 | Now we are ready to go. If you try http://localhost/app_dev.php/mod/report it should open the PDF document. PDF is the default format but you can change to any format supported by !OpenOffice.org. in the view class (explained later). |
|---|
| | 102 | |
|---|
| | 103 | == Document format == |
|---|
| | 104 | |
|---|
| | 105 | The action view is by default sfPHPView. However, Symfony provides a simple way to specify the view class depending on the action name and the action return value. Actually, sfOpenOffice plugin automatically creates a new view class {document name}SuccessView. |
|---|
| | 106 | |
|---|
| | 107 | {{{ |
|---|
| | 108 | app/ |
|---|
| | 109 | modules/ |
|---|
| | 110 | clients/ |
|---|
| | 111 | actions/ |
|---|
| | 112 | actions.class.php |
|---|
| | 113 | views/ |
|---|
| | 114 | listSuccessView.class.php |
|---|
| | 115 | }}} |
|---|
| | 116 | |
|---|
| | 117 | The class listSuccessView can have some methods like getFileExtension and getOutputExtension (note that this is an evolving API). You can override the latter to decide which output extention will be used. sfOpenOffice plugin will determine the correct filter to convert the document from getFileExtension value to getOutputExtension value. See config/app.yml shipped with the plugin. |
|---|
| | 118 | |
|---|
| | 119 | == One action, multiple outputs == |
|---|
| | 120 | |
|---|
| | 121 | The same action could result in different documents as regular symfony templates. As stated, the action return value decides which view is used. So if you want to have different outputs just return different values or specify the view class. |
|---|
| | 122 | |
|---|
| | 123 | For instance you could have: |
|---|
| | 124 | |
|---|
| | 125 | {{{ |
|---|
| | 126 | app/ |
|---|
| | 127 | modules/ |
|---|
| | 128 | clients/ |
|---|
| | 129 | actions/ |
|---|
| | 130 | actions.class.php |
|---|
| | 131 | views/ |
|---|
| | 132 | listDocumentView.class.php |
|---|
| | 133 | templates/ |
|---|
| | 134 | listSuccess.php |
|---|
| | 135 | listError.php |
|---|
| | 136 | documents/ |
|---|
| | 137 | list.odt |
|---|
| | 138 | }}} |
|---|
| | 139 | |
|---|
| | 140 | The action executeList can return sfView::SUCCESS (by default), sfView::ERROR or sfOpenOfficeDocumentView::DOCUMENT. The latter causes Symfony to load the class listDocumentView which is the sfOpenOffice view. So depending on the return value the client will see diferent results. Much like Symfony templates right? |
|---|