1

I have a self written TYPO3 extension (I used ext:extension_builder to create it)

My top-level TypoScript looks like this:

page = PAGE
page.10 = FLUIDTEMPLATE
page.10 {
    format = html
    file = EXT:cmsp/Resources/Private/Templates/User/Default.html
    partialRootPaths {
        10 = EXT:cmsp/Resources/Private/Partials/
    }
    layoutRootPaths {
        10 = EXT:cmsp/Resources/Private/Layouts/
    }
    templateRootPaths
        10 = EXT:cmsp/Resources/Private/Templates/
    }
    variables {
        content_main < styles.content.get
        content_main.select.where = colPos = 0
    }
}

I used a simple Fluid Styled Content template:

<f:link.action controller="user" action="search" class="btn btn-secondary">action link</f:link.action>

The search action is registered in ext_localconf.php:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'SimpleParser.Cmsp',
    'Cmspfe',
     [
         'User' => 'list,search'
     ],
     // non-cacheable actions
     [
         'User' => 'list,search'
     ]
);

I have also a template Search.html:

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Search" />

<f:section name="content">
    <h1>Search Template</h1>

    <f:flashMessages />

    <table  class="tx_cmsp" >
        <tr>
            <th> </th>
            <th> </th>
        </tr>
    </table>
     <form action="SearchConfim.php">
        Searchterm: <input type="text" name="sTerm"><br>
<input type="submit" value="Submit">
</form> 
</f:section>
</html>

The problem is that I cannot create or follow a link in the website frontend from top-level Default.html (FLUIDTEMPLATE object) to Search.html (Extbase controller template):

<f:link.action controller="user" action="search" class="btn btn-secondary">action link</f:link.action>

I just stay on Default.html all the time, even when I click an action link of my controller. I can create external links with

<f:link.external ... ></f:link.external>

The external link is working but I cannot use a link to access Search.html. Perhaps the problem is that I use a TypoScript which does not activate the controller (in a right way). But I'm happy if anyone can help me.

Oliver Hader
  • 4,093
  • 1
  • 25
  • 47
  • 1
    Sorry capital U didn't work. The link is [link]http://localhost/my-new-project/public/index.php?id=1&tx__%5Baction%5D=search&tx__%5Bcontroller%5D=User&cHash=dffabf13e973c371d14fb2e34b23d1a0[/link] Even a capital S for search doesn't do the job. Typo3 9.5.13; PHP 7.2.24-0ubuntu0.18.04.1 – christian2222 Dec 26 '19 at 12:55
  • Thanks, the `tx__` revealed what's going on and that you place ` – Oliver Hader Dec 26 '19 at 13:37

2 Answers2

0

Your controller name is User with an uppercase U. Use the same name in your f:link.action, if the controller is not being changed you can even remove this parameter.

Jonas Osburg
  • 1,733
  • 1
  • 14
  • 17
0

It seems that Default.html is the name of the top-level rendering template in FLUIDTEMPLATE. So, I assume that <f:link.action ... tag is placed in that file - at least the currently generated link seems to confirm it and looks like the following:

index.php?id=1
&tx__%5Baction%5D=search
&tx__%5Bcontroller%5D=User
&cHash=dffabf13e973c371d14fb2e34b23d1a0

It uses tx__ as prefix which actually should be something like tx_cmsp_cmspfe (the combination of your extension name and the corresponding plugin name to be used).

Brief explanation

  • Default.html template is outside of the Extbase scope and thus does not know about the current extension, controller and plugin that shall be used
  • usually links appear in templates of the same extension (e.g. in Resources/Private/Templates/List.html)
  • otherwise according scope has to be defined explicitly (like shown below)

Solution for placing link to Extbase plugin in top-level rendering template

This example can be used outside the Extbase scope on Default.html template for the current page layout - however, it explicitly has to use the correct Extbase plugin scope:

<f:link.action
    action="search"
    controller="User"
    pluginName="Cmspfe"
    extensionName="Cmsp"
    pageUid="4321"
    class="btn btn-secondary">

    action link
</f:link.action>
Oliver Hader
  • 4,093
  • 1
  • 25
  • 47
  • I'm sorry but it seems that your given action link also does not work.I think that I completely misunderstand something about extbase and the controller actiovation...? – christian2222 Dec 26 '19 at 16:00
  • Ok, what does "it does not work" mean, what result are you getting now, did the generated link change? Please try to describe your scenario better and what you try to achieve in your setup - otherwise it's quite difficult to give any support. – Oliver Hader Dec 26 '19 at 16:29
  • I can see the link in the frontend, but when I click on it I stay on the same page all the time. All I wnat was a link to the other fluid template Search.html. But I stay on my Default.html everytime I click a link – christian2222 Dec 26 '19 at 16:33
  • Hm, unfortunately that does not reveal any details - let's try it this way: * What is the location in file system of the `Default.html` file? * What is the location in file system of the `Search.html` file? * What is the UID of the page in the TYPO3 backend having the plugin content element of your custom Extbase application? As an alternative, you could also share a link to some Git repository having the sources of your current scenario. – Oliver Hader Dec 26 '19 at 17:17
  • I pushed the extension to https://github.com/christian2222/examlple The files Default.html and Search.html are in the folder examlple/Resources/Private/Templates/User/ The controller is in examlple/Classes/Controller/ My page in the backend has id 1. – christian2222 Dec 26 '19 at 18:56
  • I see, Extbase application templates and site package templates seem to be mixed (`Default.html` belongs to site package and is independent from `UserController`, `Search.html` in same directory however relies on a Extbase context). Anyway, the Extbase plugin (title "spFrontend") needs to be added in the TYPO3 backend as content element in order to actually execute the application. Maybe you can find more input at https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/4-FirstExtension/7-configuring-the-plugin.html – Oliver Hader Dec 26 '19 at 19:26
  • Unforntunately I must have donesomething completely wrong. Both my ext_localconf.php and tt_content.php are right. I also followed your docs-link and both filesshould be alright. I don't yet understand why I don't call an extbase fundtion and I don't know why my typoscript seem to be wrong...? Also Search.html is a modified copy of Default.html. And my head is perhabs not ready to accept why these two files are so different. – christian2222 Dec 27 '19 at 11:07
  • I don't think that I can solve my problem, but thank you Oliver very much for your help so far – christian2222 Dec 27 '19 at 15:05