Expanding the fluid_styled_content menu in TYPO3 7 - typo3

I am looking for a way to expand the fluid_styled_content menu in TYPO3 7, and not sure how to proceed. For example the Type1 Menu has the following code:
<ce:menu.directory pageUids="{pageUids}" as="pages">
<f:if condition="{pages}">
<ul class="ce-menu ce-menu-1">
<f:for each="{pages}" as="page">
<li>
<f:link.page pageUid="{page.uid}">
{page.title}
</f:link.page>
</li>
</f:for>
</ul>
</f:if>
</ce:menu.directory>
Now I'm looking for a way to expand the menu so it shows subpages when available.
If this page has subpages, show list with subpages (As a nested UL tree).
How can this be done with Fluid?

I do not know the view helper you are using (<ce:menu.directory />). I guess it takes a list of page uid´s and gets there children (menu.directory) and put them into a array/ObjectStorage ({pages}) - It could also just create an array of selected page uid´s and then this answer will not be correct.
You can always use the view helper <f:debug>{variableName}</f:debug> to debug what you have.
Try this:
<ce:menu.directory pageUids="{pageUids}" as="pages">
<f:if condition="{pages}">
<ul class="ce-menu ce-menu-1">
<f:for each="{pages}" as="page">
<li>
<f:link.page pageUid="{page.uid}">
{page.title}
</f:link.page>
<ce:menu.directory pageUids="{page.uid}" as="subPages">
<f:if condition="{subPages}">
<ul class="level-2">
<f:for each="{subPages}" as="subPage">
<li>
<f:link.page pageUid="{subPage.uid}">
{subPage.title}
</f:link.page>
</li>
</f:for>
</ul>
</f:if>
</ce:menu.directory>
</li>
</f:for>
</ul>
</f:if>
</ce:menu.directory>
If above dosen´t work then try to dump {page} in the debug tag and update your question with the output.

Related

Display a list of non-archived related news with Fluid

I'm trying to show a list of related news articles in detail view (working) but I want to render "only non-archived entries"
Is this possible with Fluid and how? Maybe with filters?
My code is pretty standard. Nothing special:
...
<f:for each="{newsItem.allRelatedSorted}" as="related">
<li>
<span class="news-related-news-date"><f:format.date format="{f:translate(key:'dateFormat')}">{related.datetime}</f:format.date></span>
<n:link newsItem="{related}" settings="{settings}" title="{related.title}">
{related.title}
</n:link>
<f:render partial="Detail/FalMediaContainer" arguments="{media: related.falMedia, settings:settings}" />
<f:render partial="Detail/MediaContainer" arguments="{media: related.media, settings:settings}" />
</li>
</f:for>
...
Thank you!

TYPO3 9.5 languageNavigation doesn't take query parameters when switching language (e.g. News Detail) using route-enhancer

I have a fluid template language navigation in which i use bootstrap which looks like follows:
<f:for each="{config.lang.uid}" as="lang" iteration="iterator">
<f:if condition="{languageNavigation.{iterator.index}.available}">
<f:then>
<a
href="{languageNavigation.{iterator.index}.link}"
class="dropdown-item{f:if(condition: '{languageNavigation.{iterator.index}.active}', then: ' active')}"
hreflang="{config.lang.hreflang.{lang}}"
title="{config.lang.title.{lang}}"
>
<span>
<f:if condition="{settings.navbar.langFlags}">
<core:icon identifier="{config.lang.flag.{lang}}" size="small" />
</f:if>
{config.lang.title.{lang}}
</span>
</a>
</f:then>
<f:else>
<span class="dropdown-item text-muted">
<f:if condition="{settings.navbar.langFlags}">
<core:icon identifier="{config.lang.flag.{lang}}" size="small" />
</f:if>
{config.lang.title.{lang}}
</span>
</f:else>
</f:if>
</f:for>
when I'm in the detail view of a news article and I switch the language, the parameters of the query are not translated, so it basically sends me to an empty detail page
I've been trying for hours to fix this problem but I don't seem to find a solution……
I use route enhancer to translate the detail view URLs query into the news title
the nearest i've found is to add following to the link:
addQueryString="TRUE" addQueryStringMethod="GET"
but this only seems to work in < f:link.page > and I can't use
href="{languageNavigation.{iterator.index}.link}"
in <f:link.page>
i've tried with < link.typolink > as well but in both methods i lose the language-switching-goal, even if i use
lang={config.lang.hreflang.{lang}} which would translate to en-US or de-DE in the site configuration……… it just renders the link to the detail page in the current language for all links in menu
any help? I think i've reached my capabilities to solve this
I'd be grateful for any solution
-----------------Example------------------
lets say i have the following URL which is a page with the news plugin detail view of an article:
https://my.domain/news/detail/news-title
When I go to my language navigation of this page the domains rendered are:
EN: https://my.domain/news/detail/
DE: https://my.domain/de/news/detailansicht/
so, the /news-title at the end basically gets lost
If I'm navigating only in german site and I'm standing in the news list page:
https://my.domain/de/news/
from there, all links are rendered correctly, so if i go to the list item of article in question it would send me to:
DE: https://my.domain/de/news/detailansicht/news-title
So, that's what I mean with the question, the problem only appears when I'm already in the detail view page, and I want to switch the language with the navbarmenu.
instead of rendering
https://my.domain/LANG/news/detail/news-title it renders
https://my.domain/LANG/news/detail/
Did you tried the LanguageMenuDataProcessor? With it, the links are
all correct. See:
https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ContentObjects/Fluidtemplate/Index.html?highlight=languagemenuprocessor#dataprocessing
In older TYPO3 versions DataProcessing of menu was
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = languages
as = languageNavigation
}
Now it uses
10 = TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor
10 {
languages = auto
as = languageNavigation
}
This solved my Problem, thanx for the hint #Thomas Löffler
I've also updated my template to make the code more simple by getting rid of the iterator and its index:
<f:section name="Language">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="language" href="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<f:for each="{languageNavigation}" as="item">
<f:if condition="{item.active}">
<f:if condition="{settings.navbar.langFlags}">
<core:icon identifier="{config.lang.flag.{item.languageId}}" size="small" />
</f:if>
<span class="nav-label">{item.title}</span>
</f:if>
</f:for>
</a>
<div class="dropdown-menu dropdown-menu-right mt-0 language-menu">
<f:for each="{languageNavigation}" as="item">
<f:if condition="{item.available}">
<f:then>
<a
href="{item.link}" hreflang="{item.hreflang}" title="{item.title}"
class="dropdown-item{f:if(condition: '{item.active}', then: ' active')}"
>
<f:if condition="{settings.navbar.langFlags}">
<core:icon identifier="{config.lang.flag.{item.languageId}}" size="small" />
</f:if>
{item.title}
</a>
</f:then>
<f:else>
<span class="dropdown-item text-muted">
<f:if condition="{settings.navbar.langFlags}">
<core:icon identifier="{config.lang.flag.{item.languageId}}" size="small" />
</f:if>
{item.title}
</span>
</f:else>
</f:if>
</f:for>
</div>
</li>
</f:section>
Did you tried the LanguageMenuDataProcessor? With it, the links are all correct. See: https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ContentObjects/Fluidtemplate/Index.html?highlight=languagemenuprocessor#dataprocessing

Indexed Search extbase htmltags in output

I am using TYPO3 7.6.11 and indexed_search 7.6.0.
I use the extbase plugin for indexed_search and in the output it escapes the HTML-Tags to mark the searchword. For example, when I search for "search" I get this output:
Test text with<strong class="tx-indexedsearch-redMarkup">search</strong> pattern.
I found this bugfix to this problem: https://forge.typo3.org/issues/77901
But the file PageBrowsingResultsViewHelper.php doesn't look exactly the same, and even when I add the variable protected $escapeOutput = false; it doesn't change anything.
Any idea where this is come from and where I can disable the escaping?
It was another extension who overwrote a Partial of tx_indexedsearch that caused the problem.. -> Always check if the template you are working on is the one that gets outputted ;)
This happen because of format object rendering.your result will render in {row.description} object and initially there is no format set. you have to format your result({row.description}) to the HTML. For that:
Go to the search result file.
yourindexsearch/templatingpath/IndexedSearch/Partials/Searchresult.html
Here is the complete file:
<div class="fourffCom col-sm-6">
<f:format.html><h2>{row.title}</h2></f:format.html>
<f:if condition="{row.headerOnly} == 0">
<!-- Format html -->
<f:format.html>{row.description}</f:format.html>
<ul>
<li>
<p><f:translate key="result.size" /> </p>
<b>{row.size}</b>
</li>
<li>
<p class="tx-indexedsearch-text-item-crdate"><f:translate key="result.created" /> </p>
<b class="tx-indexedsearch-text-item-crdate"><f:format.date>#{row.created}</f:format.date></b>
</li>
<li>
<p class="tx-indexedsearch-text-item-mtime"><f:translate key="result.modified" /> </p>
<b class="tx-indexedsearch-text-item-mtime"><f:format.date>#{row.modified}</f:format.date></b>
</li>
<li>
</li>
<li>
<p><f:translate key="result.path" /> </p>
<b><f:format.html>{row.path}</f:format.html></b>
</li>
</ul>
</f:if>
<f:if condition="{row.headerOnly} == 1">
<!-- Format html -->
<f:format.html>{row.description}</f:format.html>
</f:if>
<f:if condition="{row.subresults}">
<p class="tx-indexedsearch-list">
<f:for each="{row.subresults.items}" as="subrow">
<f:render partial="Searchresult" arguments="{row: subrow}" />
</f:for>
</p>
</f:if>
</div>

TYPO3 fluid_styled_content - Menu when using gridelements

how can i build a TYPO3 special-Menu in fluid with tt_content Header Elements, not the "pages" ?
https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/ContentElements/Menu/Index.html
The Type-3 is a good Example, but i can only selected in the BE the Pages, not the tt_content - Elements.
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:ce="http://typo3.org/ns/TYPO3/CMS/FluidStyledContent/ViewHelpers" data-namespace-typo3-fluid="true">
<ce:menu.list pageUids="{pageUids}" as="pages">
<f:if condition="{pages}">
<ul class="ce-menu ce-menu-3">
<f:for each="{pages}" as="page">
<ce:menu.section pageUid="{page.uid}" as="contentElements" type="header">
<f:if condition="{contentElements}">
<f:for each="{contentElements}" as="contentElement">
<li>
<f:link.page pageUid="{page.uid}" section="c{contentElement.uid}">
{contentElement.header}
</f:link.page>
</li>
</f:for>
</f:if>
</ce:menu.section>
</f:for>
</ul>
</f:if>
</ce:menu.list>
</html>
I suppose you get back content elements which have "Show in Section Menus" enabled, and have the header filled and not hidden. The menu.section viewhelper does not have the possibility to filter on content element type. The type="header" argument of the view helper is not a filter for the content element type, but checks if there is a visible header_layout and the header field is not empty. I agree, the argument name type is misleading.
If you want to filter on content type (CType), add an extra "if" statement, filtering on {contentElement.CType} == header during the iteration of the content elements
<f:for each="{contentElements}" as="contentElement">
<f:if condition="{contentElement.CType} == 'header'">
<li>
<f:link.page pageUid="{page.uid}" section="c{contentElement.uid}">
{contentElement.header}
</f:link.page>
</li>
</f:if>
</f:for>
Better would be to write your own view helper for this, if you have the knowledge to do it.
First of all you should rename your question so it is clear that you want to create a content menu that works with grid_elements
I had the same problem and could not find another way but to create a small extension for that purpose since you have to modify the search query for the content. You can find it here: https://typo3.org/extensions/repository/view/gridelements_content_menu
There is currently no manual, just install the extension and include the static TS in your template. The resulting Menu might not be sorted right if your content elements are nested deeper than one level with grid_elements

Is there a way to wrap X items in TYPO3 fluid?

Using the extension DCE elements, I created a fluid template generating a li item for every item created. Now I would like to have every first to second item a wrapper. So that:
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
<li>item 5</li>
Becomes:
<ul>
<li>item 1</li>
<li>item 2</li>
</ul>
<ul>
<li>item 3</li>
<li>item 4</li>
</ul>
<ul>
<li>item 5</li>
</ul>
Is this possible in a fluid template? Perhaps in combination with Typoscript?
Solution
This is what I ended up with using {cycle} to iterate trough every 2 items, and then closing and opening the tag. As well as making sure the last item does not end with an opening tag:
<ul>
<f:for each="{field.item}" as="item" iteration="iterator">
<f:if condition="{iterator.cycle} % 2">
<f:then>
<li>item {iterator.cycle}</li>
</f:then>
<f:else>
<li>item {iterator.cycle}</li>
<f:if condition="{iterator.isLast} != 1">
<f:then>
</ul><ul>
</f:then>
</f:if>
</f:else>
</f:if>
</f:for>
</ul>
Note
I understand that with the power of VHS v:iterator.chunk would probably solve this with a little less code, but I could not get it to work how I wanted to. If anyone would be willing to provide a working example to compare the 2 options I would be grateful.
With VHS
Update: 21.12.2017
So revisited the chunk option, and the same code is achieved with the following snippet using VHS iterator.chunk:
<f:for each="{field.item -> v:iterator.chunk(count: 2)}" as="col" iteration="cycle">
<ul>
<f:for each="{col}" as="item">
<li>
test
</li>
</f:for>
</ul>
</f:for>
Perhaps this helps someone out there!
If you are using the VHS view helpers collection extension, then you can also use the Iterator\Chunked view helper:
<v:iterator.chunk count="4" subject="{menu}" as="entries">
<f:for each="{entries}" as="row">
<f:for each="{row}" as="page">
[...]
</f:for>
</f:for>
</v:iterator>
This is possible with regular Fluid, using the iterator of the for view helper.
<f:for each="{items}" as="item" iteration="itemIterator">
<f:if condition="{itemIterator.isOdd}">
<ul>
</f:if>
<li>{item.name}</li>
<f:if condition="{itemIterator.isOdd}">
<f:then>
<f:if condition="{itemIterator.isLast}">
</ul>
</f:if>
</f:then>
<f:else>
</ul>
</f:else>
</f:if>
</f:for>
The tricky part is the closing </ul> which is covered with the Fluid above.
Sure, you need the for viewhelper in addition to its counters/iterators. The you can use the if viewhelper to check for your condition.
The API has some examples: http://api.typo3.org/typo3cms/current/html/class_t_y_p_o3_1_1_c_m_s_1_1_fluid_1_1_view_helpers_1_1_for_view_helper.html#details
https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/For.html
I have one more solution, As for me - more native
<f:for each="{items}" as="item" iteration="itemIterator">
<f:cycle values="{0:'left', 1:'right', 3:'center'}" as="order">
<f:switch expression="{order}">
<f:case value="left">
<div class="left">Conetnt</div>
</f:case>
<f:case value="right">
<div class="right">Conetnt</div>
</f:case>
<f:case value="center">
<div class="center">Conetnt</div>
</f:case>
</f:switch>
</f:cycle>
</f:for>