TYPO3 9.5 Simple TMENU with broken Links - typo3

This simple TMENU https://docs.typo3.org/typo3cms/TyposcriptIn45MinutesTutorial/CreateAMenu/Index.html generates in my TYPO3 9.5 the expecting unordered list. The entries has also the correct site titles, but the links are all pointed to the Site Root /
Anybody knows why?
<ul class="level1">
<li>Über uns</li>
<li>Leistungen</li>
<li>Standorte</li>
<li>News</li>
<li>Karriere</li>
<li>Downloads</li>
<li>Kontakt</li>
</ul>
UPDATE: The reason was that all slug fields were empty.

Related

Why does bootstrap formatting not work in my typoscript?

I am using a Typo3(11.5.12) server, set up locally with xampp.
I am trying to understand how bootstrap works in typoscript, so I followed this tutorial.
The content on the site does not get formatted, even though I copied every line of typoscript.
I ensured that the 4 needed files are included in the user_upload folder and I checked that the respective paths are set correctly.
I also made sure that the fluid content elements are included.
This is the typoscript code that I copied:
# Default PAGE object:
page = PAGE
page {
meta {
author = testauthor
viewport = width=device-width, initial-scale=1.0
}
includeCSS {
10 = fileadmin/user_upload/tutorial/bootstrap/bootstrap.min.css
}
includeJS {
10 = fileadmin/user_upload/tutorial/bootstrap/bootstrap.bundle.min.js
}
100 = HMENU
100{
wrap = <nav class="navbar navbar-expand-lg navbar-light bg-light"><div class="container-fluid"><a class="navbar-brand" href="#">Navbar</a><button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>|</div></nav>
1 = TMENU
1.wrap = <ul> | </ul>
1.NO.wrapItemAndSub = <li> | </li>
1.expAll = 1
2 < .1
3 < .2
}
200 < styles.content.get
200.wrap = <div class="container mt-5">|</div>
}
This is what it is supposed to look like: https://gyazo.com/3753c5661c84372df78c9d2683b1feeb
This is what it looks like for me: https://gyazo.com/c55e9c61500c7e0eff62b79cf77071e2
Here are the 4 required files located: https://gyazo.com/21b2902e06b2e17f5bcfcb28b93a4d50
The fluid content elements are included: https://gyazo.com/f87294000fa116ffecb7329fe87b0c65
I suppose there is a problem with typoscript understanding the bootstrap code, but I have no clue why that could be. Does someone have a clue?
Disclaimer: I apologize for the images not being formatted, I don´t have 10 reputation yet.
In newer TYPO3 versions .js and .css sources cannot be in ./fileadmin. This is enforced by the Content-Security-Policy (CSP) headers which are set in the default ./public/fileadmin/.htaccess (it is generated during install from this template).
Your browser should normally show CSP blocked assets in its Devtools -> Console and/or in the network tab.
You could change/remove the CSP in that file (not really recommended but it will keep you going for that tutorial) or you could refactor all assets into a site package (recommended). It is described in this tutorial.

Display full name of logged in TYPO3 frontend user in Fluid

The task is pretty simple: I want to display the full name (first- and lastname) of the current TYPO3 frontend user in Fluid. But somehow, TYPO3 (version 9.5) or Fluid seems to cache data, so a logged in frontend user sometimes sees the name of other another logged user.
Current implementation:
TypoScript:
lib.username = USER_INT
lib.username.userFunc = Vendor\Extension\UserFunc\Username->getUsername
This is a USER_INT, so the output should always be uncached.
Fluid Layout - Default.html:
<f:render partial="Header" section="Top" />
Fluid Partial - Header.html:
<f:section name="Top">
<img src="logo.png">
<f:render partial="Navigation" />
</f:section>
Fluid Partial - Navigation.html
<f:security.ifAuthenticated>
<f:then>
<p>Logged in as: <f:cObject typoscriptObjectPath="lib.username" /></p>
</f:then>
<f:else>
<p>Not logged in</p>
<f:else>
</f:security.ifAuthenticated>
Why does the result of the cObject get cached? Should'nt this always be calculated per request, because lib.username is a USER_INT? I also tried to add a f:cache.disable ViewHelper to the template with no success.
In order to resolve the problem I refactored it to fetch the full name of the fe_user using a JavaScript XHR request to a simple PSR-15 middleware. Is this really the only suitable solution or am I missing something?
Update 17.12.2020
This all works fine. I just spotted a typo in my userFunc, which resulted in the unexpected behavior.
This happens because TYPO3 cache works with frontend user groups, not frontend users. So you will see results cached for the list of user's groups rather than the current user.
Use <v:render.uncache> ... </v:render.uncache> from EXT:vhs to render that part of code uncached. Alternatively you can modify TYPO3 caching to use the current user but this may decrease cache performance and seriously increase amount of cached items.
Beware, that there is a caching problem even with USER_INT and COA_Int see https://forge.typo3.org/issues/37988
You could use only TypoScript for that like:
lib.username = COA_INT
lib.username {
10 = TEXT
10.data = TSFE:fe_user|user|first_name
10.wrap = |
20 = TEXT
20.data = TSFE:fe_user|user|lastname_name
}
Why use TypoScript? It is very limited on what it can bring back. I just finished a tutorial where you can use a ViewHelper to add an ExtBase variable which assigns the whole user object in the FrontEnd and you can use it wherever you want with all it's relations, even the image, which is difficult to get via TypoScript.
TYPO3 tutorial
Best regards
share edit delete flag

Access flux fields from another Fluidtypo3 FCE element (flux, fluidcontent, vhs)

I'm trying to access the settings of a Fluidtypo3 FCE element. My FCE is a news article that I want to include in another FCE, which is a slider. The slider only has one field and the configuration is the following:
<flux:field.relation
name="articles"
label="News-Beitrag"
multiple="true"
size="6"
table="tt_content"
condition="AND tt_content.pid = {record.pid} AND CType = 'fluidcontent_content' AND colPos = 1 AND sys_language_uid = {record.sys_language_uid}"
minItems="1"
maxItems="10"
renderMode="default"
/>
This configuration works, I can select all my news FCE's as a relation. The field articles saves the uid's of all referenced FCE's. Now I am trying to use these uid's to receive the content. Right now my code is the following:
<f:section name="Main">
<f:if condition="{articles}">
{v:iterator.explode(content: '{articles}', glue: ",", as: 'articles')}
{v:content.get(contentUids: "{articles}", render: 0) -> v:variable.set(name: 'slides')}
<f:for each="{slides}" as="element">
</f:for>
</f:if>
</f:section>
The <v:content.get> ViewHelper gets the tt_content record as it is recorded in the database. The flux settings are stored in XML-Format in the field pi_flexform. I am trying to access those specific flux settings one by one and not just the whole pi_flexform field in xml format.
I've looked for ViewHelpers that can convert XML to an Array and tried many other things, but nothing worked for me. I am grateful for any ideas how to solve this problem.
<flux:form.data> is the Viewhelper you seek. You can use it like this:
<f:for each="{slides}" as="element">
<flux:form.data table="tt_content" field="pi_flexform" record="{element}" as="flexformData">
<!-- Do stuff with flexformData -->
</flux:form.data>
</f:for>

typo3 : how can i render page's content with fluidpages

In typo3 6.2, with fluidpage extension. (http://fluidtypo3.org/)
I create a page with 2 fluid content elements.
Im trying to render a page's content with fluid template.
This is my code :
<v:content.render column='0' pageUid="3" as="contentElement">
<f:for each="{contentElement}" as="content">
<f:debug title="Debug of MyArray">{contentElement}</f:debug>
</f:for>
</v:content.render>
Edit : sry, my mistake i didnt indeent the last line.
About debug, it change nothing, because contentElement is empty.
This displays nothing. When I check array's data, I got empty array.
Thanks in advance for you help.

Using references in GitHub wiki with restructured text

I'm trying to use internal references to link an index atop my wiki page with several sections within the document. Here's an example:
* `My index`_
+ Foreword_
+ `Technical details`_
My index
--------
Foreword
~~~~~~~~
Technical details
~~~~~~~~~~~~~~~~~
If I generate the HTML page via rest2html I get the right result. However, GitHub wiki inserts extra words in the references and the links do not work. for example:
https://github.com/myaccount/myproject/wiki/Page#wiki-my-index
https://github.com/myaccount/myproject/wiki/Page#wiki-foreword
https://github.com/myaccount/myproject/wiki/Page#wiki-technical-details
I couldn't find any relevant document in the GitHub page, so I'm kind of lost.
It looks like the class ids are missing from the generated divs. Check the page source to (not) see them. I think this is what it should look like:
<ul>
<li><dl class="first docutils">
<dt><a class="reference internal" href="#my-index">My index</a></dt>
<li><a class="reference internal" href="#foreword">Foreword</a></li>
<li><a class="reference internal" href="#technical-details">Technical details</a></li>
</ul>
<div class="section" id="my-index">
<h1>My index</h1>
</div>
<div class="section" id="foreword">
<h2>Foreword</h2>
</div>
<div class="section" id="technical-details">
<h2>Technical details</h2>
</div>
Edit: User intuited mentions the same issue in a GitHub markup issue
I've noticed this problem with README.rst files as well. As well as
headings, inline targets in .rst files, e.g. _some target, don't
work. The inline target text gets wrapped in a but doesn't get
made into any sort of link target. Should I file this as a separate
issue?