Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Typoscript improvements #643

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Classes/DataProcessing/DatabaseQueryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* bodytext = TEXT
* bodytext {
* field = bodytext
* parseFunc =< lib.parseFunc_links
* parseFunc =< lib.parseFunc_RTE
* }
* link = TEXT
* link {
Expand Down
23 changes: 1 addition & 22 deletions Configuration/TypoScript/ContentElement/Shortcut.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ tt_content.shortcut {
fields {
content {
fields {
shortcut = COA
shortcut =< lib.renderChildren
shortcut {
10 = RECORDS
10 {
Expand All @@ -13,27 +13,6 @@ tt_content.shortcut {
tt_content.stdWrap.wrap = |###BREAK###
}
}
stdWrap {
innerWrap = [|]
split {
token = ###BREAK###
cObjNum = 1 |*|2|*| 3
1 {
current = 1
stdWrap.wrap = |
}

2 {
current = 1
stdWrap.wrap = ,|
}

3 {
current = 1
stdWrap.wrap = |
}
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Configuration/TypoScript/ContentElement/Text.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tt_content.text {
bodytext = TEXT
bodytext {
field = bodytext
parseFunc =< lib.parseFunc_links
parseFunc =< lib.parseFunc_RTE
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tt_content.textmedia {
bodytext = TEXT
bodytext {
field = bodytext
parseFunc =< lib.parseFunc_links
parseFunc =< lib.parseFunc_RTE
}
gallery = TEXT
gallery {
Expand Down
2 changes: 1 addition & 1 deletion Configuration/TypoScript/ContentElement/Textpic.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tt_content.textpic {
bodytext = TEXT
bodytext {
field = bodytext
parseFunc =< lib.parseFunc_links
parseFunc =< lib.parseFunc_RTE
}
gallery = TEXT
gallery {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,40 @@ lib {
makelinks {
http {
keep = {$styles.content.links.keep}
extTarget.data = parameters:target
extTarget = {$styles.content.links.extTarget}
}

mailto {
keep = path
}
}

tags {
link = TEXT
link {
current = 1
typolink {
parameter.data = parameters : allParams
extTarget.data = parameters:target
}
parseFunc.constants = 1
}
a = TEXT
a {
current = 1
typolink {
parameter.data = parameters:href
title.data = parameters:title
ATagParams.data = parameters:allParams
target.data = parameters:target
extTarget.data = parameters:target
# the target attribute takes precedence over config.intTarget
target.ifEmpty.data = parameters:target
# the target attribute takes precedence over the constant (styles.content.links.extTarget)
# which takes precedence over config.extTarget
# do not pass extTarget as reference, as it might not be set resulting in the string being
# written to the target attribute
extTarget {
ifEmpty < config.extTarget
ifEmpty.override = {$styles.content.links.extTarget}
override.data = parameters:target
}
}
}
}

allowTags = {$styles.content.allowTags}
denyTags = *
sword = <span class="ce-sword">|</span>
# @deprecated since TYPO3 v12, remove with v13
constants = 1
nonTypoTagStdWrap {
HTMLparser = 1
Expand All @@ -51,19 +54,22 @@ lib {
parseFunc_RTE < lib.parseFunc
parseFunc_RTE {
# Processing <ol>, <ul> and <table> blocks separately
externalBlocks = article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul, pre
externalBlocks = article, aside, blockquote, div, dd, dl, footer, header, nav, ol, section, table, ul, pre, figure
externalBlocks {
ol {
stripNL = 1
stdWrap.parseFunc = < lib.parseFunc
stdWrap.parseFunc =< lib.parseFunc
}

ul {
stripNL = 1
stdWrap.parseFunc = < lib.parseFunc
stdWrap.parseFunc =< lib.parseFunc
}

pre {
stdWrap.parseFunc < lib.parseFunc
}

table {
stripNL = 1
stdWrap {
Expand All @@ -74,25 +80,34 @@ lib {
always = 1
list = contenttable
}

keepNonMatchedTags = 1
}
}

HTMLtableCells = 1
HTMLtableCells {
# Recursive call to self but without wrapping non-wrapped cell content
default.stdWrap {
parseFunc = < lib.parseFunc_RTE
parseFunc.nonTypoTagStdWrap.encapsLines.nonWrappedTag =
parseFunc =< lib.parseFunc_RTE
parseFunc.nonTypoTagStdWrap.encapsLines {
nonWrappedTag =
innerStdWrap_all.ifBlank =
}
}

addChr10BetweenParagraphs = 1
}
}

div {
stripNL = 1
callRecursive = 1
}

article < .div
aside < .div
figure < .div
blockquote < .div
footer < .div
header < .div
Expand All @@ -101,20 +116,23 @@ lib {
dl < .div
dd < .div
}

nonTypoTagStdWrap {
HTMLparser = 1
HTMLparser {
keepNonMatchedTags = 1
htmlSpecialChars = 2
}

encapsLines {
encapsTagList = p,pre,h1,h2,h3,h4,h5,h6,hr,dt
remapTag.DIV = P
nonWrappedTag = P
innerStdWrap_all.ifBlank = &nbsp;
}
HTMLparser = 1
HTMLparser {
keepNonMatchedTags = 1
htmlSpecialChars = 2
}
}
}

parseFunc_links {
htmlSanitize = 1
tags {
Expand All @@ -125,8 +143,10 @@ lib {
parameter.data = parameters : allParams
extTarget.data = parameters:target
}

parseFunc.constants = 1
}

a = TEXT
a {
current = 1
Expand Down
44 changes: 44 additions & 0 deletions Configuration/TypoScript/Helpers/RenderChildren.typoscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* This lib renders children in headless.
* To use this code copy code below and replace FIELDNAME and TABLENAME with correct values for relation
*
children =< lib.renderChildren
children.10 {
source.field = FIELDNAME
tables = TABLENAME
conf.TABLENAME.stdWrap.wrap = |###BREAK###
}
*
*/

lib.renderChildren = COA
lib.renderChildren {
10 = RECORDS
stdWrap {
innerWrap = [|]
split {
token = ###BREAK###
cObjNum = 1 |*|2|*| 3
1 {
current = 1
stdWrap {
wrap = |
}
}

2 {
current = 1
stdWrap {
wrap = ,|
}
}

3 {
current = 1
stdWrap {
wrap = |
}
}
}
}
}
2 changes: 2 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugin.tx_headless {

## Include page
@import "EXT:headless/Configuration/TypoScript/Page/*.typoscript"
## Include helpers
@import "EXT:headless/Configuration/TypoScript/Helpers/*.typoscript"
## Include content elements
@import "EXT:headless/Configuration/TypoScript/ContentElement/*.typoscript"
## Include configuration
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Developer/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ object with a header definition `lib.contentElementWithHeader`:
bodytext = TEXT
bodytext {
field = bodytext
parseFunc =< lib.parseFunc_links
parseFunc =< lib.parseFunc_RTE
}
demoSubfields {
fields {
Expand Down