create menu with baseURL in front of link (absolute links) - typo3

When I create my menu I only have relative paths for the different menu links. How do I get an absolute URL (i.e. a typolink with the baseURL in front of it).
I can think of either defining a variable or write the domain name in the wrap. E.g.
10.wrap = <option value="http://www.domain.com/|">
But are there better options?

Simply set the typolink parameter forceAbsoluteUrl of the links in your HMENU construct: http://wiki.typo3.org/TSref/typolink

Set config.absRefPrefix = http://www.yourdomain.com/sub/path/. That will prefix any properly generated site-root relative links with the domain.
There may be an alternative way using domain records (Linking across domains in multidomain-sites does exactly what you want), but I can't point you to anything there.

Related

XML Sitemap with typoscript makes wrong URLs

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)

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
}

Switch Locales in TYPO3, "live", on one page

On Set multiple locales on one page I was enlightened you can switch locales in php live, during one php call.
For example, like this:
$locale_old = setlocale(LC_TIME, 0);
setlocale(LC_TIME, 'fr_CH');
// do something
setlocale(LC_TIME, $locale_old);
What about TYPO3? I have different dates on one page that should be displayed in different languages according to the content element they're in.
As the locale that renders the date is set globally, it can't be done using these two TypoScript Settings:
config.locale_all = de_CH
config.locale_all = fr_CH
Is it possible at all - and how?
This is not possible with TypoScript, because TypoScript is not executed line by line, but rather parsed into one configuration tree which is then passed to the FrontendController (technical the call order is the other way around, but do not try to get into the inner magics of TYPO3 here).
So you either need to define your own wrapper script that you can call at the needed places with stdWrap methods or you switch to Fluid templating and create a viewhelper that does the switching for you. Inside this viewhelper you can use code you mentioned in your question.
The TypoScript setting does the setlocale() globally. Of course you can switch it while you execute your own PHP code. That means you can switch the setting (even in the FrontendController) inside your Controller or in your View.

TYPO3: getting relative URLS with "/" in the beginning

There is an extension in my TYPO3 website that uses the following line of Typoscript:
EXT:ts_example/social_bookmarks-min.js
This translates to
typo3conf/ext/ts_example/social_bookmarks-min.js?1416308825
If I use absolute URLs in my website, this is not a problem, but if I intend to use relative URLs, this won't work, as it won't replace the entire pathname of the base URL, since it does not start with "/".
In short, I wish that it would output this instead:
/typo3conf/ext/ts_example/social_bookmarks-min.js?1416308825
Is there a way to achieve this?
In your main TypoScript use:
config.absRefPrefix = /
and DON't use config.baseURL at the same time!

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.