Tobias Hartmann
Tobias Hartmann

Reputation: 1263

TYPO3 Manipulate Content Elements before rendering

We added a new field into tt_contents and also, within TCA, to all content elements. Depending on the value within this field, we want to steer if the element should be rendered or not.

The behavior is similar to the content element access control for FE Users.

I'm searching for a Hook or an idea how to solve this. Unfortunately, I could not find anything helpful within felogin, also I tried the followings Hooks.

contentPostProc
render-preProcess

System Information:

Would be absolutely awesome if someone could point me to a direction, thanks.

Update:
Had to change from a new field within the tt_contents table, to a mm relation table. This makes it more complex since the tables have to be joined.

Update:
Since there are several solutions, I tried a lot but ended with the getRecordOverlay hook. In the Interface PageRepositoryGetRecordOverlayHookInterface, which has to be used, you find a method for a pre- and a post-hook.

Upvotes: 3

Views: 952

Answers (2)

helhum
helhum

Reputation: 463

You could have a look at the enableFields hook.

https://github.com/TYPO3/TYPO3.CMS/blob/084e22c249aef27755ddc88038daedcae81f1068/typo3/sysext/frontend/Classes/Page/PageRepository.php#L1332

You can adapt the query that is used to get content element.

Upvotes: 3

Alex Kellner
Alex Kellner

Reputation: 1309

With the old TYPO3 - I think you're using css_styled_content. You can simply add a new field (e.g. a checkbox) to tt_content with your own extension and some lines of TCA (I think you know how to insert this). After this you could extend styles.content.get - something like ```

styles.content.get = CONTENT
styles.content.get {
    table = tt_content
    select.orderBy = sorting
    select.where = colPos=0 and yourfield=1
    select.languageField = sys_language_uid
}
lib.yourcontent < styles.content.get

Upvotes: 1

Related Questions