-->

TYPO3: No template was found. View could not be re

2019-07-05 05:12发布

问题:

I'm experimenting a bit with TYPO3 backend modules and I'm trying to get a view when I click my module in the left menu in the backend. However when I click this I get the following message:

Sorry, the requested view was not found. The technical reason is: No template was found. View could not be resolved for action "list" in class "MyVendor\MyModule\Controller\ConnectionController".

I have the view for the list action in the folder Resources/Private/Backend/Templates/Connection and the file is called List.html (uppercamelcase)

I'm using TYPO3 version 7.6.15 and I made this module with the extension builder.

Any help would be appreciated.

回答1:

I found the problem. For some reason the Extension Builder places the folders Templates, Layouts and Partials in a folder called "Backend". I moved these three folders to Resources/Private/ and now it works.

Weird thing it does that.



回答2:

You can also change your template root path (the relative path from where the extension takes the tempaltes):

go to the

setup.ts

file (or setup.txt file; depends on personal preferences and local configuration) and add the following line

plugin.tx_myslider.view.templateRootPath = EXT:path/to/custom/directory/

for example it could look like this:

EXT:slider/Resources/Private/Templates/myAwesomeFolder/

NOTE: slider is just a placeholder. You can simply replace it with your extension name



回答3:

Add your extension to the website node. Until you add it, the setup.ts won't work.



回答4:

Some possible reasons for this (or similar) errors:

1. Forgetting to include the TypoScript static templates

  1. Choose WEB > Template module (in Module menu)
  2. Select your start (root) page (in page tree)
  3. Select Info / Modify (in Docheader)
  4. Choose Edit the whole template record
  5. Choose tab Includes
  6. Select your extension under Available Items

This will activate the TypoScript under Configuration/TypoScript

2. Wrong path

The Template paths set via TypoScript must match the available template paths in the filesystem.

Usually, the default path is:

  • Resources/Private/Templates (for frontend plugins)

or

  • Resources/Private/Backend/Templates (for backend modules)

This must have been set correctly via TypoScript. For example:

Configuration/TypoScript/setup.typoscript:

# Module configuration
module.tx_myexample_web_myexamplelist {
    view {
        templateRootPaths.0 = EXT:myexample/Resources/Private/Backend/Templates/
...  
  • module. is for backend modules
  • if you are working with frontend plugins, use plugin. instead of module.
  • the correct file ending for TypoScript is .typoscript since TYPO3 8 and no longer .ts or .txt. For version 7, it is correct to use .ts.

3. Use correct filenames

The name of the Controller matches the name of the subdirectory in the Templates directory. The name of the template file is capitalized.

  • Controller/SomeController.php: listAction()

matches

  • Resources/Private/BackendTemplates/Some/List.html