TYPO3: configure available types for tx_news content element relation - typo3

Is it possible to configure which content element types are available for the content elements relation in tx_news records?
I have a backend layout which allows only gridelements in tt_content. The regular content elements are only allowed within a grid elements container.
Currently I face the problem, that in news records it's only possible to add grid elements:
I'd like to allow only some specific content elements in news records.
Update:
The above mentioned restriction is done via TSConfig for the BackendLayout:
mod.web_layout.BackendLayouts {
1 {
title = Standardseite
config {
backend_layout {
colCount = 1
rowCount = 1
rows {
1 {
columns {
1 {
name = Content
colPos = 0
allowed = gridelements_pi1
}
}
}
}
}
}
}
}
When I remove the line allowed = gridelements_pi1, all content element types are available again.
But regardless of the allowed setting for backend layouts I'd like to have just a small subset of content element types available for news records.

Sometimes the solution can be so simple and obvious! Thx for hint, Georg Ringer!
Just override the settings for the news sys folder:
[45 in tree.rootLineIds]
# this changes the allowed CTypes. Add more as a comma separated list
mod.web_layout.BackendLayouts.1.config.backend_layout.rows.1.columns.1.allowed = textmedia
# this sets the default CType to prevent an error with INVALID VALUE ("text")
TCAdefaults.tt_content.CType = textmedia
[global]
By the way, an even better solution would be to use TCEFORM.tt_content.CType.removeItem = ..., but this would require to update the list each time you add a new CType.

Related

Get tx_news fal_media via TypoScript to use in fluid page template

I want to use the first image out of a new entry to include in the page header.
Therefore i need the news fal_media data in TypoScript to pass it to my page fluid template.
I managed to get the first image as a file path by this TypoScript code:
lib.newsimage = FILES
lib.newsimage {
references {
table = tx_news_domain_model_news
uid.data = GP:tx_news_pi1|news
fieldName = fal_media
}
maxItems = 1
renderObj = IMG_RESOURCE
renderObj.file {
import.data = file:current:publicUrl
}
stdWrap.ifEmpty = {$settings.ext.news.imageDummy}
}
But is there a better way to do it, especially to get the data as an array of FileReferences? With a FAL FileReference i could also take crop an meta data into account.
You might use a FilesProcessor
example based on the manual:
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
as = news_images
references {
fieldName = fal_media
table = tx_news_domain_model_news
}
sorting = datetime
sorting.direction = descending
}
Although I can't imagine that this will be the correct way as there is no guarantee that the first news you select by this is the first news shown on the page. News have multiple conditions to be shown aside of basic visibility: ordering by publishing time, archived state, top-news state, groups or categories, ...
Maybe it would be easier if you use a news plugin with a special template and don't forget to enable showing of news multiple times (by default each news gets shown only once in a page)

TYPO3 Is this possible to remove add content button from backend for specific custom layout

My typo3 version is 11.5.10.
I want to remove the + Content button for specific column of our page layout:
The extension bootstrap_package is using a field like that and the trick is just to omit colPos in the backendlayout.
In the following code you can see that in the one defined column colPos is just missing:
3 {
columns {
1 {
name = LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:backend_layout.column.subnav
colspan = 3
}
2 {
name = LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:backend_layout.column.left
colPos = 1
colspan = 3
}
3 {
name = LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:backend_layout.column.normal
colPos = 0
colspan = 6
}
}
}
For the case you want to look up by yourself, it's in the TypoScript-template bootstrap_package/Configuration/TsConfig/Page/Mod/WebLayout/BackendLayouts/subnavigation_left_2_columns.tsconfig.
This solution works without any additional extension or PHP code.
That's not possible with TYPO3 core.
you might disable all possible CEs for that column if you use an additional extension: content defender
At least you can assign a column number where you skip the rendering in the front end.

How to use Page Ids retrieved from Database in the HMenu?

I'm currently working on my first typo project and need to create a mega menu with an individual set of pages.
Many attempts failed or are not suitable for me. My current shot aims to group pages of the redirect type in a hidden page. In Typoscript I want to set the ID of the parent page containing these redirections and read the shortcut IDs of the children accordingly.
pageIds = CONTENT
pageIds {
table = pages
select {
selectFields = shortcut
pidInList = 614 # Id of the container Page
}
}
The next step would be to use the retrieved shortcut IDs in my HMENU of the type 'list'.
1 = HMENU
1 {
special = list
special {
value = # Assign retrieved IDs here
}
[...]
}
Typoscript is very confusing at first sight, so I would be glad to receive some hints how I can transfer the query's result, as a comma-seperated list, to the HMENU.
Thanks in advance!
Greetz.
First, you need to get a comma-separated list of the page UIDs you want to link. This can be achieved with a renderObj:
lib.pageIds = CONTENT
lib.pageIds {
table = pages
select {
selectFields = shortcut
pidInList = 614 # Id of the container Page
}
renderObj = TEXT
renderObj.stdWrap.field = shortcut
renderObj.stdWrap.wrap = |,
}
This should give you a comma-separated list of all records. Now you must apply these to the HMENU. As you can read in the documentation, the value property is stdWrap enabled, this means that you can copy a value when you use a cObject:
1 = HMENU
1 {
special = list
special {
value.cObject < lib.pageIds
}
[...]
}
I didn't test this, so maybe the configuration is not entirely complete.

TYPO3: Special tt_contenttype. Modify content before output

Can I create a "special" type of tt_content, so text is beeing processed in some custom ways before outputtet?
In my case I would like to add ###MY_MARKER### somewhere in header and/or bodytext and have it replaced by the right words for the given page.
eg:
When visiting this page: mypage.com/?marker=test
Header in tt_content: "Welcome to ###MY_MARKER##, enjoy
Output in browser: "Welcome to TEST, enjoy"
I CAN do it by making a custom plugin. Question is more if I can reuse normal tt_contant for the same purpose
Yes, you can easily extend the tt_content by adding your own TCA configuration to the typo3conf/extTables.php file:
t3lib_div::loadTCA('tt_content');
$TCA['tt_content']['columns']['CType']['config']['items']['user_my_type'] = array(
0 => 'My custom content',
1 => 'user_my_type',
2 => 'i/tt_content.gif',
);
$TCA['tt_content']['ctrl']['typeicon_classes']['user_my_type'] = 'mimetypes-x-content-text';
$TCA['tt_content']['ctrl']['typeicons']['user_my_type'] = 'tt_content.gif';
/* In the following either copy, insert and modify configuration from some other
content elemenet (you can find it in the ADMIN TOOLS -> Configuration - $TCA)... */
$TCA['tt_content']['types']['user_my_type']['showitem'] = '';
/* ...or assign it some other configuration so that it's exactly the same
as some other content type and stays the same after some update of TYPO3: */
$TCA['tt_content']['types']['user_my_type']['showitem'] = $TCA['tt_content']['types']['text']['showitem'];
After that, just set in your Typoscript template how the element is supposed to be rendered:
tt_content.user_my_type = COA
tt_content.user_my_type {
10 = TEMPLATE
10 {
template = TEXT
template.field = header
marks {
MY_MARKER = TEXT
MY_MARKER.value = TEST
}
}
20 = TEMPLATE
20 {
template = TEXT
template {
field = bodytext
required = 1
parseFunc = < lib.parseFunc_RTE
}
marks < tt_content.user_my_type.10.marks
}
}
NOTES
The Typoscript rendering is just a simplified example. You might want to add other standard configuration like in other elements, e.g. the one that adds edit icons for frontend display.
The marker in my example can be populated by the value of a GET paramater in the URL as you wanted but this would have nasty security implications. You would certainly need very good validation of that input.

How to assign two instances of the same plugins to different markers in a template

I need to insert two instances of tt_news on the same page and assign each instance of the plugin to a marker in the template. The two instances would be inserted in a backend column not rendered by my template, like border.
Since inserted plugins have a visible id on the backend, I was thinking about something like this
page.10.marks.NEWS1 < plugin.tt_news.idxxx
page.10.marks.NEWS2 < plugin.tt_news.idyyy
How can I achieve this ?
Hm... You could either insert content elements at the marker, like so
temp.contentElement = RECORDS
temp.contentElement {
tables = tt_content
dontCheckPid = 1 # if necessary
}
page.10.marks.NEWS1 < temp.contentElement
page.10.marks.NEWS1.source = UID_OF_NEWS_PLUGIN_ELEMENT
or, you could simply completely configure the plugin in ts
temp.news1 < plugin.tt_news
temp.news1 {
# configure
}
temp.news2 < plugin.tt_news
temp.news2 {
# configure
}
page.10.marks.NEWS1 < temp.news1
Hope that helps