1
votes

I have created my own TYPO3 Extension. This extension will show a list of files. In the backend i can create new categories. In these categories I can add new files. This works. But when I will link the download button to new controller action, it appears always an error.

I created a new Controller (Classes -> Controller -> DownloadController.php). The file contains the following:

namespace Mbdownloads\MbDownloads\Controller;
class DownloadController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {

/**
 * action list
 *
 * @return void
 */
public function downloadAction() {
    //$files = $this->fileRepository->findAll();
     $this->view->assign("sample_var", "sample value");
    //$this->view->assign('files', $files);
}

In the ext_localconf.php I added the following lines:

    'Mbfilelist',
array(
    'Category' => 'list,show,test',
    'File' => 'show',
    'Download' => 'download',

Then I added the following file: Resources/Private/Templates/Download/Download.html

Finally in the show action template I add the fluid downloadlink to the controller:

<f:link.action action="download" controller="Download"><i class="fa fa-download"></i> File Download</f:link.action>

Url:

index.php?id=217&tx_mbdownloads_mbfilelist%5Baction%5D=download&tx_mbdownloads_mbfilelist%5Bcontroller%5D=Download&cHash=c1ee54cc5ccaedbeeeeef098a2029e5c

But now i get only: Oops, an error occurred! :(

The only action which works is the show action?! Classes/Controller/CategoryController/showAction

If I add an action in this controller, exampleAction and I will call those action, the same error: Oops, an error occurred!

Thanks for help! I use TYPO3 6.2.16 ...

1
Set Development preset in Install tool and you will get more details about error. One of problems can be cache. Try to clear all cache from Install tool.smitrovic
Ok i have cleared all caches, dont work, then i have activated the debug options, it says: The controller "Download" is not allowed by this plugin. My ext_localconf.php looks like: \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( 'Mbdownloads.' . $_EXTKEY, 'Mbfilelist', array( 'Category' => 'list,show', 'File' => 'show', 'Download' => 'download', ), // non-cacheable actions array( 'Category' => 'list,show', 'File' => '', )Johannes Regner
Try to clear typo3temp folder. It should help :)smitrovic
I have deleted all files in typo3temp folder, cleared all cache in install tool, cleared system cache, frontend cache ... the same :/Johannes Regner
Strange, if you add 'Download' => '' to non-cacheable actions? Also, do you use "switchablecontroleractions"? This can be cause of problems like this. Try also to create two separate plugins if this is the case.smitrovic

1 Answers

1
votes

Did you add your action in flexform?

<switchableControllerActions>
    <TCEforms>
        <label>Select Options</label>
        <onChange>reload</onChange>
        <config>
            <type>select</type>
            <items>
                <numIndex index="0">
                    <numIndex index="0">...Select Item...</numIndex>
                </numIndex>
                <numIndex index="1">
                    <numIndex index="0">Download</numIndex>
                    <numIndex index="1">ControllerName->action;Download->download</numIndex>
                </numIndex>
            </items>
        </config>
    </TCEforms>
</switchableControllerActions>

After you add controller name and action, also you have to update your FE plugin element.