{"id":26208984,"url":"https://github.com/davidbruchmann/wdb-content-conditions","last_synced_at":"2025-10-16T17:59:39.402Z","repository":{"id":57681095,"uuid":"494040615","full_name":"DavidBruchmann/wdb-content-conditions","owner":"DavidBruchmann","description":"This extension adds two different TypoScript conditions to check if content elements with special values on a site exist.","archived":false,"fork":false,"pushed_at":"2024-03-27T17:29:04.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-16T07:18:53.477Z","etag":null,"topics":["conditions","typo3-cms-extension","typo3-extension","typoscript","typoscript-conditions"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DavidBruchmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-19T11:21:34.000Z","updated_at":"2022-06-26T02:17:54.000Z","dependencies_parsed_at":"2022-09-14T11:12:46.117Z","dependency_job_id":null,"html_url":"https://github.com/DavidBruchmann/wdb-content-conditions","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidBruchmann%2Fwdb-content-conditions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidBruchmann%2Fwdb-content-conditions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidBruchmann%2Fwdb-content-conditions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidBruchmann%2Fwdb-content-conditions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DavidBruchmann","download_url":"https://codeload.github.com/DavidBruchmann/wdb-content-conditions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243172082,"owners_count":20247883,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conditions","typo3-cms-extension","typo3-extension","typoscript","typoscript-conditions"],"created_at":"2025-03-12T06:33:35.729Z","updated_at":"2025-10-16T17:59:34.367Z","avatar_url":"https://github.com/DavidBruchmann.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TYPO3 extension \"WDB Content conditions\"\n\nThis extension adds a TypoScript condition to check if content elements\nwith special values on a site exist.\nIncluded are two conditions, **`ttContent()`** and **`tt_content[]`**:  \n\n 1. A functional condition  \n    This is verifying all content elements on a page  \n    The syntax is:  \n    \n    **`ttContent([fieldname], [expected value], [type of value])`**  \n    \n    **return value: bool / array**  \n    \n    **Parameters:**\n    \n    - **`fieldname`**: the field to verify.\n    - **`expected value`**: the value that shall be checked, optional.\n    - **`type of value`**: the datatype of the value, optional.\n    \n    Due to the return value, and the limit of available operators, it's NOT\n    useful to combine it with further comparisons like `a \u003e b`. Nevertheless\n    several conditions can be used together concatenated with `||` (OR)\n    or `\u0026\u0026` (AND).  \n    \n    **Important** to understand is that no content elements are returned, but\n    that the new condition is doing most often a boolean check.  \n    That means that above any condition the content elements have the same amount\n    and properties like below, **content elements are not filtered** by the condition.  \n\n    **Note that all queries exclude deleted or hidden records without exception.**  \n    \n 2. An array condition to a verify single content element\n    This can be used to check properties of single elements and even combine several\n    to check several properties of single elements.\n    The syntax is:  \n    \n    **`tt_content[uid][fieldname]`**  \n\n    **return value: string / integer**  \n    Return values are just what is saved in the database, this doesn't respect any\n    relations to files or other records.\n    \n    **Array Keys:**\n    \n    - **`uid`**: the unique id for the `tt_content` record to verify.\n    - **`fieldname `**: the field to verify.\n    \n\n\n## Use case for the additional condition:\nChecking for values in content elements allows to include special CSS, JS or\nto configure other page- or config-related values only if it's required.  \n**Example:**  \n```\n[ttContent(\"list_type\", \"tx_myextension_pi1\", \"str\")]\n    page.includeCSS.mySlideshow = EXT:my_extension/Resources/Public/Css/mySlideshow.css\n    page.includeJSFooter.mySlideshow = EXT:my_extension/Resources/Public/JavaScript/mySlideshow.js\n[global]\n```\n**Explanation:**\n- **`ttContent()`** is the name of the condition and according to the database-table with\n  the same name. For beginners it might be confusing that there still exists a variable\n  in TypoScript with the same name too. Nevertheless, the usage of `ttContent()` as condition\n  is the only one with round brackets, because it's a function.\n- The first parameter **`\"list_type\"`** is the name of the field that shall be checked.\n  Naming conventions for this field name are defined by the database and must not include\n  spaces, minus, brackets or many other characters.  \n- The second parameter **\"tx_myextension_pi1\"** is the value that is supposed to be found\n  as value for a content element in the field **`\"list_type\"`**.  \n  Naming conventions for this value are defined by TYPO3 and must not include\n  spaces, brackets or many other characters.  \n- The third parameter is the data type of the value and used to assign a constant\n  for DBAL (the framework to access the database). It can be `\"int\"`, `\"str\"`, `\"bool\"` or more.\n  Important is that this should be `\"int\"` for integer values, everything else is not so\n  important and can be `\"str\"`.  \n  For some fields with boolean values like `hidden` as example, the value `\"int\"` for this\n  parameter can be used too, as TYPO3 stores boolean values usually as integers (0 or 1).  \n\n\n### Special use case: manipulating content rendering\nCertainly it's also possible to change definitions for rendering of content elements\nbased on properties of one (perhaps even unreleated) content element. This could be\nmenus but also other content elements. Nevertheless, as neither the content elements\nnor the rendering definitions of a page are filtered, those changes would\nrelate to all content elements on the page.  \n**Example:**  \nThe condition `[ttContent(\"header_layout\", 3, \"int\")]` checks in all content elements\non a page if the value 3 is saved in the field `header_layout`. Imagine there is one\nrecord, that has this value and this record's headline shall be wrappedd additionally\nto the h3-tag with the em-tag. But the code `tt_content.header.stdWrap.wrap = '\u003cem\u003e|\u003cem\u003e'`\nwould wrap the headlines of all content elements, no matter which value they have assigned.\n\n\n@TODO: whats about operators like \u0026\u0026, xor, etc.?  \n@TODO: whats about FlexForm values?  \n@TODO: test null-values  \n@TODO: update examples below, `ttContent(field, value, type)` example: `[ ttContent(\"tx_webcan_st_bt_element\", 5, \"int\") ]`  \n\n## Examples for the functional condition:  \n\n**`[ttContent(\"colPos\", 1, \"int\")]`**  \nChecks if the field `colPos` of a `tt_content` record on the page has the value 1.  \n\n**`[ttContent(\"subheader\")]`**  \nChecks if the field `subheader` of any `tt_content` record on the page is filled.  \n\n**`[ttContent(\"header\", \"Home\", \"str\")]`**  \nChecks if the field `header` of a `tt_content` record on the page has the value \"Home\".\n\n**`[ttContent(\"header\", \"Home\", \"str\") || ttContent(\"header\", \"Homa\", \"str\")]`**  \nChecks if the field `header` of a `tt_content` record on the page has the value \"Home\" or \"Homa\".\n\n**`[ttContent(\"header\", \"Home\", \"str\") \u0026\u0026 ttContent(\"header\", \"Homa\", \"str\")]`**  \nChecks if the field `header` of a `tt_content` record on the page has the value \"Home\" and another \n`tt_content` record the value \"Homa\".  \nThis example might explain that the data are coming from a pool of records and that a conclusion if these \nare coming from the same record is usually not possible. If the requested fields are the same, combined\nby an AND (\u0026\u0026), surely they can't come from the same record. So it's impossible with this condition,\nto check if two different properties (field values) belong to the same record.\n\n## Examples for the condition in array form:  \n\n**`[tt_content[15][\"colPos\"] == 1]`**  \nChecks if the field `colPos` of the `tt_content` record with the `uid` 15 on the page has the value 1. \n\n**`[tt_content[15][\"subheader\"]]`**  \nChecks if the field `subheader` of the `tt_content` record with the `uid` 15 on the page is filled.  \n\n**`[tt_content[15][\"header\"] == \"Home\"]`**  \nChecks if the field `header` of the `tt_content` record with the `uid` 15 on the page has the value \"Home\".\n\n**`[tt_content[15][\"header\"] == \"Home\" || tt_content[15][\"subheader\"] == \"Welcome\"]`**  \nChecks if the field `header` of the `tt_content` record with the `uid` 15 on the page has the value \"Home\"\nOR the field `subheader` the value \"Welcome\".\n\n**`[tt_content[15][\"header\"] == \"Home\" \u0026\u0026 tt_content[15][\"subheader\"] == \"Welcome\"]`**  \nChecks if the field `header` of the `tt_content` record with the `uid` 15 on the page has the value \"Home\"\nAND the field `subheader` the value \"Welcome\".\nThis example shows that the data are coming from the same record and it can be be useful to have the `uid`\nof a distinct record to verify something.  \nString comparisons like in this example might be useful to combine with a 3rd condition of the\nsame kind, verifying the field `sys_language_uid` for the record-language:\n**`[tt_content[15][\"header\"] == \"Home\" \u0026\u0026 tt_content[15][\"subheader\"] == \"Welcome\"] \u0026\u0026 tt_content[15][\"sys_language_uid\"] == 1]`**  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidbruchmann%2Fwdb-content-conditions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidbruchmann%2Fwdb-content-conditions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidbruchmann%2Fwdb-content-conditions/lists"}