Search code examples
phptypo3apache2typoscript

The technical reason is: No template was found. View could not be resolved for action "search" in class "LoginController"


Im new to typo3 and ive been trying to develop an extension for it. When I load the plugin to the page i get and error:

Sorry, the requested view was not found.

The technical reason is: No template was found. View could not be resolved for action "search" in class "LoginController".

In the login controller i have a function searchAction and I do have a template inside

  • \Resources\Private\Templates\StoreInventory\Search.html

What might be the error? I followed the documentation for extension development by typo3. I even downloaded the code from GIT and tried using that but no luck.


Solution

  • TL;DR: It should be placed at Resources/Private/Templates/Login/Search.html

    explanation: From your question I can tell you've used the documentation on https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/4-FirstExtension/6-adding-the-template.html It is not wrong, but you've missed a vital step. When you take a look at the path they are using you'll see that a lot is done automagically. Let's break it down.

    They have a controller with an action and a template related to it in the following path

    • controller: \MyVendor\StoreInventory\Controller\StoreInventoryController
    • action: listAction
    • template: EXT:store_inventory/Resources/Private/Templates/StoreInventory/List.html

    If you look closely you'll see that the template path is made up from several components.

    1. the extension (EXT:store_inventory)
    2. the default template directory path (Resources/Private/Templates)
    3. The Controller name without the controller suffix (StoreInventory)
    4. the Action name without the action suffix (List)
    5. the .html suffix

    If you take that information and apply it to your case it would be:

    1. the extension (EXT:your_extension_name)
    2. the default template directory path (Resources/Private/Templates)
    3. The Controller name without the controller suffix (Login)
    4. the Action name without the action suffix (Search)
    5. the .html suffix

    So the end result would be something like

    EXT:your_extension_name/Resources/Private/Templates/Login/Search.html
    

    It is true that you can use typoscript to change this behaviour or set overrides or extended templating for instance. But I think you're working from the default, and this should be the working path for you now