Last active
January 17, 2024 21:28
-
-
Save froemken/53c74e8445dcbf0cfda4be57079b5e30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show possible errors | |
config.contentObjectExceptionHandler = 0 | |
lib.categories = CONTENT | |
lib.categories { | |
table = sys_category | |
select { | |
# Adapt to your needs | |
pidInList = root | |
# Set a recursive level if needed | |
# recursive = 2 | |
leftjoin = sys_category_record_mm ON sys_category.uid = sys_category_record_mm.uid_local | |
where.dataWrap = sys_category_record_mm.tablenames = 'sys_file_metadata' AND sys_category_record_mm.fieldname = 'categories' AND sys_category_record_mm.uid_foreign = {CURRENT:1} | |
} | |
# Render categories: cat1, cat2, cat3, | |
renderObj = TEXT | |
renderObj { | |
field = title | |
noTrimWrap = ||, | | |
} | |
# remove last space because of noTrimWrap above | |
stdWrap.trim = 1 | |
# remove last comma because of noTrimWrap above | |
stdWrap.substring = 0, -1 | |
} | |
config.contentObjectExceptionHandler = 0 | |
# Show categories of table tt_content | |
tt_content.text.dataProcessing { | |
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor | |
10 { | |
table = sys_category | |
selectFields = sys_category.uid, sys_category.title | |
pidInList = root | |
join = sys_category_record_mm ON sys_category.uid = sys_category_record_mm.uid_local | |
where.dataWrap = sys_category_record_mm.tablenames = 'tt_content' AND sys_category_record_mm.fieldname = 'categories' AND sys_category_record_mm.uid_foreign = {FIELD:uid} | |
as = contentCategories | |
} | |
} | |
# Show categories of table pages | |
page.10.dataProcessing { | |
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor | |
10 { | |
table = sys_category | |
selectFields = sys_category.uid, sys_category.title | |
pidInList = root | |
join = sys_category_record_mm ON sys_category.uid = sys_category_record_mm.uid_local | |
where.dataWrap = sys_category_record_mm.tablenames = 'pages' AND sys_category_record_mm.fieldname = 'categories' AND sys_category_record_mm.uid_foreign = {FIELD:uid} | |
as = pageCategories | |
} | |
} | |
# Within the Fluid Template use. And YES, use it with the prepended dot in data attribute: | |
<f:cObject typoscriptObjectPath="lib.categories" data="{file.originalFile.metaData.}" currentValueKey="uid" table="sys_file_metadata" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Be careful with
recursive
in large websites! Withrecursive = 99
(as posted on StackOverflow) the entire pagetree is queried page by page for its subpages to build the list of IDs. On a site with 10T pages this caused (uncached) almost 25,000 SQL queries.