How to get viewhelper f:widget.autocomplete working in TYPO3 8.7 - autocomplete

I want to use the viewhelper f:widget.autocomplete to implement an autocomplete feature for a search in a little extension in TYPO3 8.7.
The Documentation for TYPO3 8.7. says nothing about it: https://docs.typo3.org/m/typo3/guide-extbasefluid/8.7/en-us/Fluid/ViewHelper/Widget/Autocomplete.html
I tried it as discribed in the Documentation for TYPO3 9.5. https://docs.typo3.org/other/typo3/view-helper-reference/9.5/en-us/typo3/fluid/latest/Widget/Autocomplete.html
I have included the JS- and CSS-Assets and use the viewhelper in the filter-form of my extension:
<input type="text" id="search" name="pluginname[search]" />
<f:widget.autocomplete for="search" objects="{myobject}" searchProperty="name" />
This integrates a JS-Snippet from sysext/fluid and makes an ajax call, if I put something in the text field.:
http://host/index.php?id=1&type=7076&fluid-widget-id=305d544b2a96a8e5a73db7e93c083586&action=autocomplete&term=myterm
But the response to this call contents the hole page and not only the result of a datatabase query according to my searchterm.
Now my question:
What have I to do, to get the autocomplete feature working?
Do I need an extra autocomplete action in my controller?
Or ist there an extra setup for the pageType needed?
Currently the pageType 7076 is configured by the Fluid-Sysextension:
fluidAjaxWidgetResponse = PAGE
fluidAjaxWidgetResponse {
# todo: make page type configurable
typeNum = 7076
headerData >
config {
no_cache = 1
disableAllHeaderCode = 1
additionalHeaders.10.header = Content-Type: text/plain
additionalHeaders.10.replace = 1
debug = 0
}
10 = USER_INT
10 {
userFunc = TYPO3\CMS\Fluid\Core\Widget\Bootstrap->run
}
}
config.tx_extbase {
mvc {
requestHandlers {
TYPO3\CMS\Fluid\Core\Widget\WidgetRequestHandler = TYPO3\CMS\Fluid\Core\Widget\WidgetRequestHandler
}
}
}

Related

TYPO3 render Event from typoscript and Fluid template

In TYPO3 10.4.8 I have the following page tree:
root
1level: Events
2level: Event A, Event B, Event C, ... and so ...
What I want to do in page Events is to render all subpages title, using FLUIDTEMPLATE.
So in the template of page Events I wrote
lib.EventContent = COA
lib.EventContent {
10 = COA
10{
table = pages
select {
orderBy = sorting
pidInList = this
}
}
}
and in the layout file
<f:for each="lib.EventContent" as="event" >
<p>event: {event.title}</p>
</f:for>
This doesn't work. Typo give me this error:
The argument "each" was registered with type "array", but is of type "string" in view helper "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper".
In addition, I also tried to change COA with CONTENT, in all possible combination (COA-CONTENT / CONTENT-COA / CONTENT-CONTENT)
What's wrong? is something that I cannot do?
Thanks all
The TypoScript should look something like this:
lib.EventContent = CONTENT
lib.EventContent {
table = pages
select {
orderBy = sorting
pidInList = this
}
}
But there is a much easier solution. TYPO3 already brings a content element "Subpages" which renders a menu of all subpages of a selected page:
This is done via Fluid Styled Content and TypoScript. Please check this file for details:
typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/MenuSubpages.typoscript
A solution for you might look like this (untested):
lib.EventContent < tt_content.menu_subpages
lib.EventContent {
dataProcessing {
10 {
special >
}
}
}
It's also a good idea to have a look in all the TypoScript files in the Fluid Styled Content extension to get more inspiration.

How can I get a rootline / breadcrumb within an Extbase Frontent Plugin in TYPO3

Is there a way to work with dataProcessing / MenuProcessor within an Extbase Frontend Plugin in TYPO3 9?
I want to build a page rootline within a plugin. I know how to make it in page context or in a tt-content element but can I get it in a plugin too?
I tried the following in my plugin setup, but this does not work:
plugin.tx_extensions_show {
view {
...
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = rootline
special.range = 1|-1
includeNotInMenu = 1
as = rootline
}
}
}
}
Inside your plugin code you can fetch the rootline in an array:
// ($MP and $this->context are optional)
$rootline = GeneralUtility::makeInstance(RootlineUtility::class, $uid, $MP, $this->context);
$rootlinePages = $rootline->get();
Now you can pass $rootlinePages on to your FLUID template.
Hth.
Based on the hint of Loek to do it in the controller an not in the fluid template I found my own solution to fetch the rootline in an array and pass it to my Fluid template for TYPO3 9:
$rootLineUtility = new \TYPO3\CMS\Core\Utility\RootlineUtility($GLOBALS['TSFE']->id);
$rootline = $rootLineUtility->get();
$this->view->assign('rootline', $rootline);

How to include Header.html partial in TYPO3 ver 9

I want to change the Layout of my Headers in TYPO3. There is a post about this but this but I cant get it to work and that post is 2 years old. With TYPO3 most stuff is outdated quite quickly. This is the post.
Additionally I looked at this article. I know it is in German, maybe it helps anyways.
So I copied the Header.html from the TYPO3 system files, put it in a directory under fileadmin and tried to link to that directory.
fileadmin/.../Partials/Header/Header.html
In the Template setup i added the partialRootPath.
page = PAGE
page {
shortcutIcon = fileadmin/sitedesign/Resources/Private/Templates/Vave/img/Favicon.ico
10 = FLUIDTEMPLATE
10.file = fileadmin/sitedesign/Resources/Private/Templates/Vave/Contact/index.html
10.partialRootPath {
20 = fileadmin/Resources/Private/Partials
}
includeCSS {
contactFile1 = fileadmin/sitedesign/Resources/Private/Templates/Vave/Contact/css/Contact.css
}
}
In Header.html I created an additional case to check if it was working.
<f:case value="7">
<p class="{positionClass}">
<f:link.typolink parameter="{link}">{header}</f:link.typolink>
</p>
</f:case>
I then added that new case in the Page Resources to the TSConfig.
TCEFORM.tt_content.header_layout {
addItems.7 = Name1
}
Changing the content of the Header.html file in the TYPO3 system files works the way I expected it to, so I am quite sure that I understand the basic functionality. The TSConfig part works as well, because I can select "Name1" in the Header Layout Type field.
But no matter what part in the fileadmin Header.html version I change, nothing happens. I checked the path to that Partials folder and the spelling of everything a million times, so I do not think that is the issue either.
Of course I could just change the system file Header.html but that seems wrong on a lot of levels.
Thank you for any help.
Don't mix different usages of fluid!
You want to change the header partial of your content elements.
But you add the new partial to the fluid of page rendering.
if you use FSC (Fluid Styled Content) your additional partial path should go here:
lib.contentElement {
partialRootPaths {
10 = fileadmin/Resources/Private/Partials
}
}
breaking change: lib.contentElementinstead of lib.fluidContent
Additional advices:
be carefull with the names: aside from partialRootPaths there sometimes exist partialRootPath (without s in the end), which is not an object array. That enables you to set only one path (not the usual path list with priority) and which has priority over settings in partialRootPaths if both exist.
separate the different fluid usages!
Give them different paths. There are multiple ways. I prefer:
each extension gets it's own three folders in a folder named for the extension.
And also separate the page rendering and CEs (Content Elements). Your own CEs might be considered as part of the extension 'FSC'.
use a site extension.
All configuration goes into that extension: typoscript, templates, viewhelpers, TCA, ...
That is the basic configuration for that site, but also the additional configuration/ adaption for the used extensions.
May this code will help you!!
page = PAGE
page {
shortcutIcon = fileadmin/sitedesign/Resources/Private/Templates/Vave/img/Favicon.ico
10 = FLUIDTEMPLATE
10 {
templateName = TEXT
templateName {
cObject = TEXT
cObject {
data = levelfield:-2,backend_layout_next_level,slide
override.field = backend_layout
required = 1
case = uppercamelcase
split {
token = pagets__
cObjNum = 1
1.current = 1
}
}
ifEmpty = Innenseite
}
#templateName=TEXT
# templateName.value=index
layoutRootPaths {
20 = your layoutRootPaths
}
partialRootPaths {
20 = your partialRootPath
}
templateRootPaths {
20 = your templateRootPath
}
}
includeCSS {
contactFile1 = fileadmin/sitedesign/Resources/Private/Templates/Vave/Contact/css/Contact.css
}
}
Make sure header included properly in main template

File list is not rendered in typo3 frontend

After updating from TYPO3 4.5 to 6.2, File lists are not rendered in the frontend anymore.
# Default PAGE object:
page = PAGE
page.typeNum = 0
page.stylesheet = fileadmin/template/design.css
page.20 = TEMPLATE
page.20 {
template = FILE
template.file = fileadmin/template/templ.html
workOnSubpart = document
subparts.cont = CONTENT
subparts.cont {
table = tt_content
select.orderBy = sorting
select.where = colPos = 0
}
This is the TypoScript Setup I was using before; it should the standard rendering routine for Text (that is working) and Images (this is working as well), but for some reason there's only an empty ul block:
<!-- File list: [begin] -->
<ul class="csc-uploads csc-uploads-0"></ul>
<!-- File list: [end] -->
I don't know what is going wrong...
I found the mistake. TYPO3 was still set to run "as TYPO3 4.5" compatibility mode. Going through the Upgrade wizard again and finally use TYPO3 6.2, everything is now working.
Bottom line: TYPO3 4.5 compatibility mode is not actual producing the same output as TYPO3 4.5!

TYPO3 tx_news extension not using override template

I have two sites using the tx_news extension. As far as I can tell they are set up identically. On site A I have added a new List.html partial and it works as expected. On site B however it is completely ignoring my List override.
I have triple checked the file path to make sure the typoscript points to the right place but it still uses the default. What could be wrong here?
plugin.tx_news {
view {
templateRootPaths >
templateRootPaths {
0 = EXT:news/Resources/Private/Templates/
1 = fileadmin/templates/example/news/Templates/
}
partialRootPaths >
partialRootPaths {
0 = EXT:news/Resources/Private/Partials/
1 = fileadmin/templates/example/news/Partials/
}
layoutRootPaths >
layoutRootPaths {
0 = EXT:news/Resources/Private/Layouts/
1 = fileadmin/templates/example/news/Layouts/
}
}
}
To make it work as expected I would do the following:
1) Copy the three folders from ext/news/Resources/Private/Templates, Partials, Layouts to fileadmin/templates/example/news
(I believe you have already done that)
2) Then place this in to your template provider or page typoscript constants:
plugin.tx_news {
view {
templateRootPath = fileadmin/templates/example/news/Templates/
partialRootPath = fileadmin/templates/example/news/Partials/
layoutRootPath = fileadmin/templates/example/news/Layouts/
}
}
Now the news extension will use the Template files placed in fileadmin/
Next step would be to add some pageTSConfig inside your root pages properties in case you need more flexibility. For example like this:
tx_news.templateLayouts {
1 = Special List Item
2 = Special Detail Layout
}
That allows you to select one of these template layouts in your news plugin and to use conditions in your template file:
<f:if condition="{settings.templateLayout} == 1">
<f:then>
<!-- markup for a special list item -->
</f:then>
<f:else>
<!-- markup for another list item -->
</f:else>
</f:if>
Your script looks good. When something like this happens in TYPO3 there is an option to check whatever your TypoScript valid or this changes are really added into the right place.
Go into the BE, select the Template module and with the TypoScript Object Browser you can see if in your Setup every changes are there or not. (Or if you may have a syntax error)