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

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).

Related

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.

GitHub hosted Jeykll site. Background images within css are not displaying?

I've created a settings.yml within a _data folder. This also contains my baseurl: /run-and-roll.
So I have inserted {{ site.data.settings.baseurl }} in front of my assets. The css file is loading along with images that are defined in the html. However, any background images requested in the css are not showing?
https://granttransition.github.io/run-and-roll/
Every configuration variable that appears in https://jekyllrb.com/docs/configuration/ makes sense to keep them there.
Usually templates preppend the base url when generating some urls like the ones of the assets, using {{site.baseurl}}, so if you manually sets it from another location it won't be used by default.
What you have read that is a good practice to have settings and config separate is for every other configuration not related exactly with jekyll built-in variables, that it is a good practice to put them on data files, so you keep your _conf.yml as clear as possible as the official docs suggests, that makes easier to maintain and update your Jekyll instance:
In addition to the built-in variables available from Jekyll, you can
specify your own custom data that can be accessed via the Liquid
templating system.
Jekyll supports loading data from YAML, JSON, and CSV files located in
the _data directory. Note that CSV files must contain a header row.
This powerful feature allows you to avoid repetition in your templates
and to set site specific options without changing _config.yml.
Plugins/themes can also leverage Data Files to set configuration
variables.
TL;DR
just put baseurl in _config.yml as suggested in other answers :)
b/c if you are using Jekyll with Github Page, then if site.url or site.baseurl are not specified, in a CNAME or config.yml, for the production build. then they will be set automatically by github page generator
Explanation
from github page generator code-source:
# Set `site.url` and `site.baseurl` if unset and in production mode.
def set_url_and_baseurl_fallbacks!
return unless Jekyll.env == "production"
repo = drop.send(:repository)
site.config["url"] ||= repo.url_without_path
if site.config["baseurl"].to_s.empty? && !["", "/"].include?(repo.baseurl)
site.config["baseurl"] = repo.baseurl
end
end
the default build environment for jekyll, is development. So while, working on your site locally. every thing will run just as you expect. even when putting baseurl in other location than _config.yml
but in github page side, the web site is built with this command:
JEKYLL_ENV=production jekyll build
and site.url and site.baseurl are overridden.
in your case, if you're using {{ site.data.settings.baseurl }} to access some page, and it's set to a value like ('' or '/') you may not notice a navigation issue. bat assets path for css and js will not work as expected.
So, just put baseurl in the _config.yml, refactor your layout and pages accordingly. and you'll be fine.
a side note: as mentioned in #David answer, it's the jekyll convention to put website setting. in _config.yml, but if you want to put them in other place, you can. just make sure, to declare them for the production build as will.
see also: Clearing Up Confusion Around baseurl -- Again
UPDATE
even after moving the website to a github project repo: /<user-name>.github.io/<repo-name> instead of user (or organization) repo: /<user-name>.github.io. you need to set as follows:
site.baseurl: ''
or just remove it. since you serve your website from the main repository (cf. above refence)
Use of {{ site.baseurl }} is a jekyll convention, moving it to a data file is not a good idea.
Nevertheless from your css standpoint, path to runner.jpg will always be ../assets/img/runner.jpg. No need to use baseurl.

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.

blank.html is downloaded multiple times

GWT is used and the application is deployed on WebLogic using HTTPS.
The performance is poor and with F12 Developer Tools, we could see that blank.html is downloaded multiple times. This is clearly related to GWT but we have not been able to figure out why.
The following is from javascript:
defineSeed(2613, 2614, makeCastMap([Q$BaseModelData, Q$ModelData, Q$Theme, Q$Serializable]), Slate_0);
var SLATE;
function $clinit_GXT(){
$clinit_GXT = nullMethod;
IMAGES = new XImages_generatedBundle_0;
MESSAGES = new XMessages__0;
SSL_SECURE_URL = getModuleBaseURL() + 'blank.html';
}
This is from GWT.java:
/**
* URL to a blank file used by GXT when in secure mode for iframe src to
* prevent the IE insecure content. Default value is 'blank.html'.
*/
public static String SSL_SECURE_URL = GWT.getModuleBaseURL() + "blank.html";
Does anyone know under what circumstances blank.html is called?
Thanks!
This is from GWT.java:
This is actually from GXT.java.
This is used in a few cases when creating an <iframe> element, so that IE won't give errors if your site is hosted from SSL. I can actually only find one case (as of GXT 3.1.1) which uses this, in Layer.java. Only IE pages loaded from https urls will make use of this.
The Layer class uses this as a "shim", a way to prop up some DOM elements above overs, and work around some browser bugs (typically plugin or iframe related). Menus and popup dialogs use this to ensure that they don't appear "underneath" content that they should be "above".
This file is very small - just enough HTML to convince IE than the iframe has correctly loaded, and no more. It never changes, and should load nearly instantly.
As far as performance goes, this should only happen when a Menu or Window/Dialog/Tooltip is shown - these shouldn't be happening on app startup usually, at least not more than a window or two. Additionally, the browser should recognize that it is loading the same element and cache it correctly, and not load it multiple times (though it might be listed several times as hitting the cache). If the server has instructed the browser to never cache the file, that is something you should look at changing.
In short, this is very unlikely to be the cause of any performance issues, at least in GXT itself. If somehow you have the shim enabled on every single widget in your project, this should not be required. If the file is loading slowly, something may be very wrong with your server configuration.
For reference, here is the entire file:
<html></html>

TypoScript: Check if JS/CSS File is already included

anybody knows how to check if a js/css file is already included with typoscript?
Example
[Template_A.ts]
page.includeJS {
jsfile = fileadmin/Template/js/jquery-1.10.2.min.js
}
now if i got an extension with the same include e.g.
[Extension_A.ts]
page.includeJS {
jsfile = fileadmin/Template/js/jquery-1.10.2.min.js
}
Is there a way to prevent this kind of double code injection? Maybe i got another Template e.g. Template_B.ts where jquery is not included - than the Extension_A.ts has to include jquery by itself.
Kinldy
You can use the same key inside includeJS such it just gets overridden if you include the file twice.
Other than that you should put jQuery into includeJSlibs, such that it is loaded before the other JS files.
Other than that, the TS should be unique for each page. Therefore you always to make sure anyway that all resources are included in-order.
You should not include JS libs with the automatic extension TS setups. Use your documentation to tell the integrator what needs to be included and what not.
The various and independent inclusion of scripts by plugins and templates is one of the tricky points in TYPO3. As far as I know, this point cannot be managed at one single point.
There is a plugin "t3jquery" that offers to build, compress and share a common jQuery library. It also has a service to analyze other plugins for their dependencies. But this doesn't solve the problem in general, as many plugins don't check for libraries already loaded.
The most stable way is to remove all plugin's references to libraries manually in your TypoSkript. This gives you some simple additional TypoSkript lines. I use lines like these:
plugin.tx_imagecycle_pi1.file.jQueryLibrary >
plugin.tx_imagecycle_pi1.jQueryLibrary >
plugin.tx_multicontent_pi1.file.jQueryLibrary >
plugin.tx_multicontent_pi1.jQueryLibrary >
# Fluid
page.headerData.998 >
You can find the matching TypoSkript descriptors by searching for the library name in the TypoSkript browser or by greping in the plugin's source code. You will also need this if you wish to add libraries as part of content that was get by AJAX, thus separating the libs from the page content.
Here's a tut (in German): http://jweiland.net/typo3/typoscript/javascript-manuell-entfernen-oder-einbinden.html
Futher possibilities you can check:
Some plugins are written in good structure and offer to keep back their Javascript in the settings.
Some script inclusions may come rather from the static template but from a plugin, so don't forget to have a look there.