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 538ff97 commit a8a255b
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 25 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
43 changes: 23 additions & 20 deletions Configuration/TypoScript/ContentElement/ParseFunc.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,35 @@ 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
extTarget.ifEmpty.override = {$styles.content.links.extTarget}
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,7 +49,7 @@ 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
Expand Down Expand Up @@ -82,7 +80,10 @@ lib {
# Recursive call to self but without wrapping non-wrapped cell content
default.stdWrap {
parseFunc = < lib.parseFunc_RTE
parseFunc.nonTypoTagStdWrap.encapsLines.nonWrappedTag =
parseFunc.nonTypoTagStdWrap.encapsLines {
nonWrappedTag =
innerStdWrap_all.ifBlank =
}
}
addChr10BetweenParagraphs = 1
}
Expand All @@ -93,6 +94,7 @@ lib {
}
article < .div
aside < .div
figure < .div
blockquote < .div
footer < .div
header < .div
Expand All @@ -102,19 +104,20 @@ lib {
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 Down
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
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
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

0 comments on commit a8a255b

Please sign in to comment.