Why does bootstrap formatting not work in my typoscript? - typo3

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.

Related

TYPO3 RTE convert <img> to <amp-img>

I have a TYPO3 version 6.2 website and I am working on a AMP version.
I use a condition in URL to load different versions of the same TYPO3 page depending if the page version request is AMP or not.
Regular version of the page :
https://www.novethic.fr/actualite/environnement/climat/isr-rse/rencontre-avec-danone-un-des-rares-francais-a-aligner-sa-strategie-sur-l-objectif-2-c-145150.html
AMP version of the page
https://www.novethic.fr/amp/actualite/environnement/climat/isr-rse/rencontre-avec-danone-un-des-rares-francais-a-aligner-sa-strategie-sur-l-objectif-2-c-145150.html
Everything works fine except if my page contains image inserted in the RTE
In this case I would need to convert <img> to <amp-img>for images inserted in the RTE when the version asked is AMP.
I already have a global var condition to load custom TS when AMP version is called.
But no idea how to convert <img> to <amp-img>
Any idea on how to achieve that?
if it is only a replacement of the tag name you could try to use a (conditioned) string replacement on one of these levels:
the whole page.
you could do a stdWrap.replacement, but that might not work on cached content
the page content in fluid.
just use a viewhelper to replace text of rendered content. that even could be a typoscript VH:
(<f:cObject typoscriptObjectPath="lib.img2ampimg">{content}</f:cObject>)
the page content in typoscript.
depending wether you render your content with TS you might add stdWrap.replacement there:
.
page {
10 = FLUIDTEMPLATE
10 {
:
variables {
content < styles.content.get
:
}
}
}
[--your amp condition--]
page.10.variables.content.stdWrap.replacement {
1.search = <img
2.replace = <amp-img
}
[global]
Maybe this could be achieved with the extension "Content Replacer", https://extensions.typo3.org/extension/replacer
I've solved it as Bernd Wilke suggested , but directly in my fluid template :
<f:if condition="{f:cObject(typoscriptObjectPath:'lib.conditionamp')} == 1">
<f:then>
<v:format.replace substring="<img " replacement="<amp-img layout=\"responsive\"">
<f:format.html>{article.corpsDeTexte}</f:format.html>
</v:format.replace>
</f:then>
<f:else>
<f:format.html>{article.corpsDeTexte}</f:format.html>
</f:else>
</f:if>
Thanks again for your help
:)

Conditional hiding of tt_content div for plugin in Frontend

I am using TYPO3 8 and fluid_styled_content.
In am developing an extension with the following requirements: If specific conditions are met (depending on URL query parameter) nothing should be displayed for the plugin in the Frontend. In this case, the fluid output of the plugin will be empty (depending on a variable that is set in the Controller). But TYPO3 still - by default - renders a wrapping div and the header.
So, essentially, what I get is something like:
<div id="c217" class="...">
<header>
<h2 class="...">Header</h2>
</header>
<p> <!-- plugin output here is empty -- > </p>
</div>
How do I (dynamically) prevent that?
This has been asked before, but the solutions I found will not work with fluid_styled_content:
You should use the FSC way.
All content is rendered with templates which use layouts and partials. Aside from the simple CEs you have a template for plugins which requests a layout which renders the header.
Enhance the (global) layout with a special condition for your plugin to avoid the header (be sure to render the header by yourself) or avoid the header if your plugin will not render any output.
EDIT:
add the override template-pathes to FSC:
lib.contentElement {
templateRootPaths {
200 = EXT:your_extension_key/Resources/Private/FSC/Templates/
}
partialRootPaths {
200 = EXT:your_extension_key/Resources/Private/FSC/Partials/
}
layoutRootPaths {
200 = EXT:your_extension_key/Resources/Private/FSC/Layouts/
}
}
now you can copy the default-layout from the FSC folder to your layout folder and add in that layout a condition which skips the header and global wrapping if your plugin is rendered.
<f:if condition="{data.CType} == 'list' && {data.list_type} == 'myPlugin'">
<f:then>
<f:comment> only plugin output </fcomment>
</f:then>
<f:else>
<f:comment> original output with headers and wrap </fcomment>
</f:else>
</f:if>

TYPO3 8.7.1 templating problems

I started using TYPO3 8.7.1 some days ago - no prior experiences in TYPO3.
I am at the point that I am using the t3editor to create a first test template using the guide that's been offered on the official page, which is for version 7. Are there huge differences in templating between those two versions, because I am only getting a blank page and even my source code shows nothing in between the body tags.
# Default PAGE object:
page = PAGE
# Define that we use a Template and where it is located
page.10 = TEMPLATE
page.10 {
template = FILE
template.file = fileadmin/tmp/home.html
}
# Insert shortcut icon in the head of the website
page.shortcutIcon = fileadmin/img/favicon.ico
# Insert stylesheet in the head of the website
page.includeCSS.base = fileadmin/css/style.css
On that note I have another question. I can't seem to find regularity for the highlighting colors used by the t3editor, but at the same time I can't find any errors in this snippet.
Can anyone help?
Best regards
An example with FLUIDTEMPLATE:
In TypoScript Setup:
page = PAGE
page {
10 = FLUIDTEMPLATE
10 {
template = FILE
template.file = fileadmin/Templates/Html/Page/Templates/Default.html
layoutRootPath = fileadmin/Templates/Html/Page/Layouts/
variables {
content < styles.content.get
}
}
}
fileadmin/Templates/Html/Page/Layouts/Default.html
<f:render section="Main" />
fileadmin/Templates/Html/Page/Templates/Default.html
<html>
<head>
<title>Page Template Default</title>
</head>
<body>
<f:layout name="Default"/>
<f:section name="Main">
<f:format.raw>{content}</f:format.raw>
</f:section>
</body>
Then insert content and show the page.

Typo3: Sub-page Template not loading

Maybe I'm just missing something ... obviously, and so far I've googled up nothing to help.
the issue, seems simple, I'm just trying to load a "slightly" different for one Page in my Root tree. All other pages share the Root template, but I need for this one page to have a completely different kind of content and a slightly different header, thus the need for a secondary template.
I've done the following for it:
# Default PAGE object:
page = PAGE
# Define the template
page.10 = TEMPLATE
# Our template is a file
page.10.template = FILE
# Our template file is fileadmin/template/media/media.html
page.10.template.file = fileadmin/template/media/media.html
But all this leads too is a completely blank HTML upon page load. No errors, no nothing! The page source just comes up:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--
This website is powered by TYPO3 - inspiring people to share!
TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
TYPO3 is copyright 1998-2013 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
Information and contribution at http://typo3.org/
-->
<link rel="shortcut icon" href="http://192.168.206.11/introductionpackage-6.1.0/fileadmin/template/media/favicon.ico" type="image/x-ico; charset=binary">
<link rel="icon" href="http://192.168.206.11/introductionpackage-6.1.0/fileadmin/template/media/favicon.ico" type="image/x-ico; charset=binary">
<title>Media</title>
<meta name="generator" content="TYPO3 6.1 CMS">
<link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_15a396fd13.css?1369410324" media="all">
<link rel="stylesheet" type="text/css" href="fileadmin/template/style.css?1369398600" media="all">
</head>
<body>
</body>
</html>
So, I suppose the question is, how can I get a single Page to have a separate template?
A typical error can be you forgot to include the default page typoscript template because the typoscript object page in your code needs it to show the content or pull it from the database. In the template configuration of template look in the include static typoscript template and include css.styled.content.
Don't know if this is correct, but this is what I found to do.
I made my template and placed it in a specific folder. Then I did the following and it works!
# Default PAGE object:
# page = PAGE
page.10 = NULL
page.includeJSlibs.jwplayer = 1
page.includeJSlibs.jwplayer = fileadmin/template/js/jwplayer/jwplayer.js
# Define the template
page.20 = TEMPLATE
# Our template is a file
page.20.template = FILE
# Our template file is fileadmin/template/media/media.html
page.20.template.file = fileadmin/template/media/media.html
# Insert shortcut icon in the head of the website
page.shortcutIcon = fileadmin/template/media/favicon.ico
# Insert stylesheet in the head of the website
# page.stylesheet = fileadmin/template/style.css
# Work with the subpart "DOCUMENT"
# page.20.workOnSubpart = DOCUMENT
######################################################
#
# Configuration of SUBPARTS
#
######################################################
# Define the subparts, which are inside the subpart DOCUMENT
page.20.subparts {
}
######################################################
#
# Configuration of MARKERS
#
######################################################
# Define the markers inside the subpart DOCUMENT
page.20.marks {
# Load the logo
LOGO = IMAGE
LOGO.file = fileadmin/templates/images/logo.png
LOGO.altText = Mountain Top
# Menu 1 cObject
menu_1 = HMENU
}
# First level menu-object, textual
page.20.marks.menu_1.1 = TMENU
page.20.marks.marks.menu_1.1 {
# Normal state properties
NO.allWrap = <li> | </li>
# Enable active state and set properties:
ACT = 1
ACT.allWrap = <li class="active"> | </li>
}
# Second level menu-object, textual
page.20.marks.menu_1.2 = TMENU
page.20.marks.menu_1.2 {
# Normal state properties
NO.allWrap = <div class="menu1-level2-no"> | </div>
# Enable active state and set properties:
ACT = 1
ACT.allWrap = <div class="menu1-level2-act"> | </div>
}

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?