[TYPO3-mvc] Referencing a PHP file, using Extbase

Adrien Crivelli adrien.crivelli at gmail.com
Wed Aug 1 15:48:26 CEST 2012


Hello,

The short answer is do not avoid Extbase.

I actually did it very recently, have at look at my code:

   1. The action's *controller* where you can define custom headers:
   https://github.com/Ecodev/newsletter/blob/1.3.0/Classes/Controller/RecipientListController.php#L135
   2. The *view*, note the "csv" file extension and be careful with
   whitespace not to break CSV content:
   https://github.com/Ecodev/newsletter/blob/1.3.0/Resources/Private/Templates/RecipientList/export.csv
   3. A *ViewHelper* to easily output CSV values:
   https://github.com/Ecodev/newsletter/blob/1.3.0/Classes/ViewHelpers/CsvValuesViewHelper.php

To switch between format, add a "&tx_myextension_myplugin[format]=csv" to
URL (or better, use UriBuilder).

Cheers,

Adrien


On 1 August 2012 21:38, Robert Schneider <r.schneider at artworx.at> wrote:

> Hi,
>
> this is maybe an stupid request. I don't know. I'm still new to
> Typo3/Extbase and even PHP.
>
> I have to create a CSV download (export) in the backend module of an
> extension. Therefore I created a PHP script to make such things like:
>
> header("Content-type: text/csv");
> header("Content-Disposition: attachment; filename=file.csv");
> header("Pragma: no-cache");
> header("Expires: 0");
> ...
> and then generating the file content (there is no physical file).
>
> This is not inside a class that is derived from an Extbase class (like
> ActionController). So the script is not executed or used like my extension
> classes.
>
> In my Fluid template the file is referenced with a a-tag.
>
> Now I have to access the repository of the model to get the data.
>
> If I do t3lib_div::makeInstance('**myrepository') I need to include
> class.t3lib_div.php. I have done it this way:
>
> require_once '../../../../../t3lib/class.**t3lib_div.php';
>
> Ugly... And then I have noticed that I need to include even more. Extbase
> stuff and so on. The question is, how do I include this all classes of
> typo3, extbase and what ever I need? Or ist this not possible? Do I have to
> include each file manually (e.g. RepositoryInterface)?
>
> How do I do this? The CSV is not the issue. Just accessing those classes.
> There must be simple way...
>
> Thanks and regards,
> Robert
>
> ______________________________**_________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc@**lists.typo3.org<TYPO3-project-typo3v4mvc at lists.typo3.org>
> http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**
> project-typo3v4mvc<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc>
>


More information about the TYPO3-project-typo3v4mvc mailing list