XML Sitemap with typoscript makes wrong URLs - typo3

According to http://www.typo3-probleme.de/2018/07/11/typo3-sitemap-mit-typoscript-erstellen-2285/ I let TYPO3 V8.7.24 generate the sitemap.xml file. So far it works. But in the file there are not proper URL's. On every URLs end is "?type=500001", for example an URL looks like "https://www.domain.ch/angebot/online-marketing/?type=500001". As a side note , there is also Ext:Realurl in use.
My request is, how can you remove the segment "?type=500001" ? Is the reason typoscript or the extension Realurl? How can I analyse it?
Any hint is welcome. Thanks in advance for your help.

It's the link generation inside of TYPO3. that is configured by typoscript, so you could see typoscript as the culprit.
If you want to know whether realurl (or any other extension) is the culprit: disable the extension in mind. if the error is gone there is a reason to suspect this extension.
When links are generated by TYPO3 it holds some parameter to stay in the current context. Which paramaters should be considered is a configuration (so it is grounded in typoscript).
Have a look (TSOB) at config.linkVars in general (it is copied implicit to every page object) or of your page object page.config.linkVars (in your case: xml_sitemap.config.linkVars)
There is a note in the manual:
Do not include the type parameter in the linkVars list, as this can result in unexpected behavior.
Other option would be to explicit set &type=0 to every link. But don't forget to set config.uniqueLinkVars = 1 (or xml_sitemap.config.uniqueLinkVars = 1)

Related

TYPO3 - how to remove cHash in f:link.action to uncached action?

EDIT: the answer of #Wolffc is totally correct - i had a false return value so the problem was between chair and screen.
TYPO3 10.4.8
I’m generating a link in a Mail with <f:link.action> to validate a subscription to a Course.
It must not be cached, so i can check if the link is already clicked, but there is a cHash added to the link.
<f:link.action
action="validate"
pluginName="Coursevalidation"
extensionName="myextension"
controller="Course"
pageUid="1"
absolute="1"
pageType="1921"
noCache="1"
noCacheHash="1"
arguments="{validationHash: subscription.validationHash, course:course, subscription:subscription}"
>Link</f:link.action>
the documentation says noCache and noCacheHash should not be used (“you should not need this”), and it makes no difference if I add it.
The PageType is uncached, 1921.config.no_cache = 1
The generated link results in (linebreaks for better readability):
https://mydomain.ddev.site/email-validation
?no_cache=1
&tx_myextension_coursevalidation%5Baction%5D=validate
&tx_myextension_coursevalidation%5Bcontroller%5D=Course
&tx_myextension_coursevalidation%5Bcourse%5D=3
&tx_myextension_coursevalidation%5Bsubscription%5D=30
&tx_myextension_coursevalidation%5BvalidationHash%5D=40e83[...thats long ;)...]0d65c
&cHash=5d7688ac4f04a2d31a98f2cffb792e51
As you can see, theres a cHash.
First klick on the Link triggers my mechanism to check everything and set the subscription to valid , and redirect to the “Success”-Page, what is exactly what it should do.
The second klick opens the success-page too, but there should be the message “Already validated”.
That page is opened, when I call the Link without the cHash.
Why is there a cHash added and how can I remove it?
Thanks :)
You must define this action as uncached in ext_localconf.php
TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin
If the plugin action is uncached typo3 will handle that correctly.
The cHash is a checksums over the request parameters and is mainly used to prevent cache bloat attacks. If an attacker generates random parameter sets. If cHash is invalid. The result will not be cached. But the reverse is not true. If cHash is valid it might still be that the parts of the page uncached. (Or even the whole page)

How to get the Log In Form on every page? (for example in footer) Typo3

Is there a way to get the Log In Form for Frontend User on every page? I would prefer the footer.
And if someone is logged in you can see the Log Out Button.
Is this possible without an extension?
You can copy the default felogin output to wherever you want on your template. For example use lib.login, copy the plugin.tx_felogin_pi1 into it, change the template and you're fine.
lib.login < plugin.tx_felogin_pi1
lib.login.templateFile = path/to/your/template/file
More you can see in the official documentation: https://docs.typo3.org/typo3cms/extensions/felogin/8.7/Configuration/Index.html
In general there are three options to include a CE (e.g. the Login-form) on all pages:
use typoscript to generate the CE. Normally the CEs are defined in tt_content, from where you could copy the base configuration and adapt it. For some plugins you also find a complete configuration beyond lib (for newer extensions there you only find the settings). All the configuration must be done in typoscript.
use typoscript to render the content of a special page/ column. In this variant you have a special page only for content referenced somewhere else. Advantage: you could configure the CE in the usual way. Try to avoid referencing CEs by uid as an editor might disable or delete the current element(s) and insert a new one which would not be rendered.
use a special column in your root page and inherit the content to all subpages. Advantage: you could change the inherited content easily on each page (if this column is available in the current backend layout).
example for 3:
variables {
footer_content < styles.content.get
footer_content.select.where = colPos = 15
footer_content.slide = -1
}

Manage hierarchy / enforce priority of TS-templates

Well, there is actually another guy with exact the same problem. But until today, they didn't come up with a solution, that's why I'm asking it once again.
My entire TS is included by an extension in TYPO3 7.6.8. This works fine except with indexed_search. The TS inside my resources EXT get overwritten by the indexed_search default TS.
This is the order of the TS inside the Template-Analyzer:
SYS: TYPO3_CONF_VARS:FE:defaultTypoScript
EXT:fluid_styled_content/Configuration/TypoScript/...
... a bunch of other third party extensions ...
EXT:indexed_search/Configuration/TypoScript
EXT:templates_ext/Resources/Private/TypoScript
extbase
fluid
extensionmanager
belog
beuser
felogin
indexed_search
sys_note
realurl
So #7 is the extension which includes all my TS but it gets overwritten by #14. The only way to configure the indexed_search is inside the setup of the page template (which comes after all those above). But I want to avoid that to keep things clean.
Is there a way to prioritize a certain TS so that it doesn't get overwritten?
Open the TypoScript record, switch to the tab "Includes", at the bottom you will find the field Static Template Files from TYPO3 Extensions:. Select the value Include before all static templates if root flag is set.
Try putting the TS from your template extension inside the root page Setup field like this (adjust the path if necessary, your example says Resources/Private/TypoScript?):
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:templates_ext/Configuration/TypoScript/setup.ts">
This should make sure that it is included AFTER all the other includes (I assume you included those via the includes tab?)

Typo3: Reference about TSFE array

Where can be found references about the $GLOBALS['TSFE'] variable for typo3?
For example some code snippets report that "TSFE:id" is the id of the current page, but where can I find the reference about this variables?
There is none. Really :-(.
But you also must know that $GLOBALS['TSFE'] (TypoScript Frontend) is not just an array containing some information, TSFE also consists of objects that can be used by extensions or in TypoScript context to access data from the current page or user. E.g.
$GLOBALS['TSFE']->sys_page is an instance of \TYPO3\CMS\Frontend\Page\PageRepository
$GLOBALS['TSFE']->fe_user is an instance of \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication
So basically the documentation is spread all over the TYPO3 documentation. You will also realize that a lot of the information can be accessed or used by TypoScript or TYPO3 API without needing to parse the TSFE array.
There used to be a (incomplete) section on TYPO3's wiki, but it seems to be gone now. You can find it on the wayback machine though:
https://web.archive.org/web/20130621221807/http://wiki.typo3.org/TSref/getText
The only online "documentation" that I know of is the TYPO3 source of the TypoScript Frontend Controller (a.k.a. TSFE):
https://api.typo3.org/TYPO3_8-7/_typo_script_frontend_controller_8php_source.html
It's all of the public properties you can access directly via TS:
10 = TEXT
10.data = TSFE:fe_user|user|username

TYPO3 extension: how to find certain TS setting

I found in typo3 admin side(/typo3), you can have two ways to set up TS,
you can set up through template->root, I think TS here will affect the whole site.
you can set up through template->certain page, it will only affect this page.
So my question is:
If I want to find where(which page) has TS setting such as : code = LIST, how could I do?
Use Web > Template module it has tools, you can for an example use Template Analyzer for the search
Try querying the database in phpMyAdmin or similar. The following looks in Template Setup:
SELECT pid, config, constants
FROM sys_template
WHERE config LIKE '%code = LIST%'
Replace config with constants to look in Template Constants. pid is the page ID.
If it is not set in the TypoScript, it perhaps has been set in the plugin itself. Just check the plugin content element itself.
In the Template module, go to the page where the setting is in effect.
Use the TSOB (Typo Script Object Browser) to search for "list":
This must show you all TS for this page that contains "list".
If you don't see the setting you can run a cmd/ctrl-F Search over the entire results.
You would have to search for "[code] = LIST".
Which will lead you to the following entry:
Hovering over the label will produce the above tooltip. Copy the line number.
Now change to the Template Analyzer. Here, you can click through all cascading templates and search for the line number:
This is definitely the line that sets that value.
From the "Template hierarchy" tree you will easily find the template that contains the setting.