Skip to content

Commit

Permalink
[TASK] Typoscript improvements
Browse files Browse the repository at this point in the history
- Align latest parseFunc with TYPO3 core changes
- change default parsing of rte with correct parseFunc
- add helper for handling inline helpers
  • Loading branch information
twoldanski committed Aug 31, 2023
1 parent e7e8a2e commit c8d6856
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 64 deletions.
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
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 @@ -7,7 +7,7 @@ tt_content.textmedia {
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 @@ -7,7 +7,7 @@ tt_content.textpic {
bodytext = TEXT
bodytext {
field = bodytext
parseFunc =< lib.parseFunc_links
parseFunc =< lib.parseFunc_RTE
}
gallery = TEXT
gallery {
Expand Down
69 changes: 41 additions & 28 deletions Configuration/TypoScript/2.x/Helper/ParseFunc.typoscript
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 @@ -141,8 +159,3 @@ lib {
}
}
}





69 changes: 41 additions & 28 deletions Configuration/TypoScript/ContentElement/ParseFunc.typoscript
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 @@ -141,8 +159,3 @@ lib {
}
}
}





44 changes: 44 additions & 0 deletions Configuration/TypoScript/ContentElement/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: 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
Loading

0 comments on commit c8d6856

Please sign in to comment.