TYPO3 - how to set the <base> tag in the header of generated html pages? - content-management-system

I have inherited ownership of a website running on TYPO3 version 4.2.1. There are two pages that are not rendering correctly, and this seems to be down to a failure to load css and javascript files. Inspecting the page source, I can see that the <base href="blah..." /> tag is missing from the page header.
The question: how on Earth do I set the base url property in TYPO3!?
I have poured over the Typo3 website, edited various "typoscript" files, offered sacrafices to the PHP gods, all to no avail. The generated code still does not include the tag.
Any help appreciated. Please note it is not possible for me to "upgrade to the latest version", and my PHP knowledge is non-existant.

Adding this line to the "Setup" field of your site's main TypoScript template ought to do it:
config.baseURL = < URL here >
The "TSRef" (TypoScript Reference) is a key document for every TYPO3 site administrator -- it's available online here:
http://typo3.org/documentation/document-library/core-documentation/doc_core_tsref/current/
I recommend printing out a copy to keep at your desk, you will be referring to it frequently. (They provide it in OpenOffice format as well, to make this easy.)
Section 1.6 ("Setup") describes all the properties you can set via TypoScript's CONFIG object:
http://typo3.org/documentation/document-library/core-documentation/doc_core_tsref/4.3.0/view/1/6/#id2512147
P.S. While I wasn't going to recommend you download the latest version to fix this problem, I will recommend you download the latest version to be sure you haven't missed any security patches.

Here is how to set the baseurl within the v4.5 introduction package:
Template > Home > Edit Whole Template Record
Includes (between Options and Recources tab )
Click on the little template icon to the left of ROOT, choose Edit
Under Constants > Config, enter the base domain as shown below (leave out the <>
Rememember to clear all cache and then to Ctrl + F5 to complete refresh the browser
TS:
config {
# cat=config; type=boolean; label=Admin Panel: Turn on admin panel (mainly for testing purposes only)
adminPanel = 0
# cat=config; type=boolean; label=Debugging: Turn on debugging (testing purposes only)
debug = 0
# cat=config; type=string; label=Domain name for Base URL: (excluding slashes and protocol like http://)
domain = < ENTER YOUR DOMAIN HERE >
}

Related

DDEV accessing wrong .css-file, different home base the productive system

I'm working on a downloaded productive TYPO3 homepage (v11.5) and set it up in DDEV.
Now during my work I recognised that the base href for inclusion of user-specified .css-files are different from the productive system.
While in the productive system, the .css-file is correctly loaded from
https://mydomain.at/fileadmin/templates/assets/css/mybootstrap2.css?1636470015
it is in the DDEV environment requested from
https://mydomain.ddev.site/sternwarte-mydomain/fileadmin/templates/assets/css/mybootstrap2.css?1674722424
Which obviously added a Typo3 page references (sternwarte-mydomain/) to the path, an therefore correctly resulted in an
net::ERR_ABORTED 404
for the GET-operation as this is the wrong location.
Any hints/suggestions where my error could be.
EDIT:
Extract of the Typoscript.
Resulting sourcecode
EDIT 2:
Site configuration:
Maybe you need to set config.absRefPrefix = / in TypoScript? Or check the entry point of your site configuration.
Update:
Try to set the link to the CSS file with a slash in front, e.g. file1 = /fileadmin/templates/assets/css/mybootstrap2.css. Or try to set config.baseURL = /.

ext_conf_template - how to use settings in root.ts

I develop TYPO3 extension. And I have file ext_conf_templates with my settings. How do I use this settings in the typoscript, root.ts ?
# cat=Template_einstellung/101/0104; type=options[nein=,ja=noborder]; label=remove bottom border (only with transparent use)
template.border =
In your ext_localconf.php add below code.
$conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY]);
$border = $conf['template.']['border'];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptConstants("
plugin.tx_yourextensionkey.template.border = $border
");
Now, anywhere in your typoscript setup you can access your border variable with {$plugin.tx_yourextensionkey.template.border}. You can name this variable as you like but best practice is to use plugin and extension name prefix to make it unique across installations.
Above works for TYPO3 CMS version 8.7. I think it´s the same routine all the way down to version 6.2 but I´m not 100% sure.
You can verify that this works with the Template backend module. In the main select box select TypoScript Object Browser. Make sure that the browser select box says Constants. Now you should be able to find your new variable.

TYPO3 - Blocked loadin mixed active content in console

On my live site 'mysite.com' I see the following error message in the console:
Blocked loading mixed active content “dev.mysite.com/fileadmin/templates/fonts/glyphicons-halflings-regular.woff2”
[Learn More]
jquery-1.11.3.min.js:4:24860
Blocked loading mixed active content “dev.mysite.com/fileadmin/templates/fonts/fontawesome-webfont.woff2?v=4.7.0”
[Learn More]
jquery-1.11.3.min.js:4:24860
I have no clue how it got there and don't remember what I changed. Where do I need to look for and how can I fix this?
I do have a Development Site ... dev.mysite.com ... and for deployment I just move the new files into the live folder.
Edit: I want to fix this problem by loading the files from my live site ... but I don't know from where I'm loading those files.
As those font-files are probably loaded from CSS I assume you already load your CSS from the dev server.
Check this out in the your browser (Network-tab).
You might see it in the HTML source. But the loading also could be initiated by javascript. so you need to check that too for any references to your dev-server.
Then you need to identify the source of this inclusion. If it's in the javascript it's obvious.
The CSS includes can be initiated in multiple places. The most common are in typoscript, so first try: go to the Template Analyzer and look for your dev-server domain. Identify the template and modify it.

Caches "reload" in TYPO3?

I have an installation of TYPO3, it's made by the introduction bundle and the bootstrap_package. According to an issue on github (bootstrap_package) concerning custom styles, I add the code
page.includeCSS {
mycustomstyles = fileadmin/custom.css
}
to the setup section of the template (I'm not a TYPO3 pro obviously).
That works, but after a while (even after doing nothing over the night) this CSS file is not linked anymore. Then I have to flush the caches to get it back working.
Why?
To make sure that you are able to track down that css file from your browser console, add this to your page setup:
config.compressCss = 0
config.concatenateCss = 0
Also, where did you include that typoscript? For starters, it should be in the page template setup for your root page, so it can take effect over all the child pages.
In case this is an actual caching issue you could disable the cache with
config.cache = 0
and see if the problem persists.

In TYPO3 6.x, how to get defaultJS, when config.disableAllHeaderCode is enabled?

I set config.disableAllHeaderCode = 1 in my recent TYPO3 sites, as I want full control over the page template.
But this not only throws out the html tag etc., but also the default Js (which could be used to uncrypt mailto-Links.
One solution would be to copy this TYPO3-generated JS from the core code and insert it manually. Very simple: just set config.disableAllHeaderCode = 0, load the page once, copy the js, done. But, in case of an update or settings change, this might break.
So: is it possible to access this "default JS" via typoscript and assign it to the PAGE object?
Have a look at https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/frontend/Classes/Page/PageGenerator.php. You will see that the spam protection code is hardcoded and only added to the page output if config.disableAllHeaderCode is not set.
Therefore I don't see a possibility to do that. Therefore the answer seems to be no, unless you XCLASS the PageGenerator. I would just copy the JavaScript code; I'm using TYPO3 for some years now and wouldn't remember that the spam protection code ever changed.
There is a solution I think. Go to /typo3/sysext/cms/tslib/templates. There is a file tslib_page_frontend.html. This file is responsible for rendering the whole page including the head. You can define a new path to the above mentioned file. For example set the following code:
config.pageRendererTemplateFile = PATH_TO_YOUR_THEME//Resources/Private/Core/tslib_page_frontend.html
respectively
page.config.pageRendererTemplateFile = PATH_TO_YOUR_THEME//Resources/Private/Core/tslib_page_frontend.html
The new template file can look like the following small snippet:
###JS_INLINE###
###BODY###
That way the inline JS is still rendered (and I think the spam protections JS is inline JS - which can be stored in external files).