[英]TYPO3: tx-news - localize tag, render tags multilingual, missing step
I use tx-news in a multilingual site and need to have the tags localized, (scripted from a custom extension): 我在多语言站点中使用tx-news,并且需要对标签进行本地化(从自定义扩展中编写):
1) first step : add the fields to the table: 1)第一步 :将字段添加到表中:
ext_tables.sql : ext_tables.sql :
#
# Extend table structure of table 'tx_news_domain_model_tag'
#
CREATE TABLE tx_news_domain_model_tag (
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l10n_parent int(11) DEFAULT '0' NOT NULL,
l10n_diffsource mediumblob
);
2) second step : TCA override tag (now fully working, added 'allLanguages' selection as suggested by ralph) 2)第二步 :TCA覆盖标签(现已完全正常运行,根据ralph的建议添加了“ allLanguages”选择)
Configuration/TCA/Overrides/tx_news_domain_model_tag.php 配置/ TCA /替代/tx_news_domain_model_tag.php
<?php
defined('TYPO3_MODE') or die();
/**
* Add multilingual to tx_news_domain_model_tag
*/
$temporaryColumns = [
'sys_language_uid' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'items' => [
[
'LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages',
-1,
'flags-multiple'
],
],
'default' => 0,
],
],
'l10n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0',
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['', 0],
],
'foreign_table' => 'tx_news_domain_model_tag',
'foreign_table_where' => 'AND tx_news_domain_model_tag.pid=###CURRENT_PID### AND tx_news_domain_model_tag.sys_language_uid IN (-1,0)',
],
],
'l10n_diffsource' => [
'config' => [
'type' => 'passthrough',
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tx_news_domain_model_tag',
$temporaryColumns
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tx_news_domain_model_tag',
'paletteCore',
'sys_language_uid, l10n_parent, l10n_diffsource',
'before:hidden'
);
/* ADDED MISSING SYNTAX AFTER PAUL'S ANSWER */
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['languageField'] = 'sys_language_uid';
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['transOrigPointerField'] = 'l10n_parent';
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['transOrigDiffSourceField'] = 'l10n_diffsource';
3) third step : TCA override news to limit tags to the language 3)第三步 :TCA覆盖新闻以将标签限制为该语言
Configuration/TCA/Overrides/tx_news_domain_model_news.php 配置/TCA/Overrides/tx_news_domain_model_news.php
/**
* Add This to the original **`tags`** column
*/
...
'foreign_table_where' => ' AND tx_news_domain_model_tag.sys_language_uid IN (-1, 0) ORDER BY tx_news_domain_model_tag.title',
...
4) fourth step : add the localization to the TCA of tx_news_domain_model_tag (added paul's answer to step 2, this is NOT missing anymore) 4)第四步 :将本地化添加到tx_news_domain_model_tag的TCA中(添加了保罗对步骤2的回答,这不再丢失了)
the following should be added but I don't know how ... (from a custom extension, I obviously can add it directly within 'news') 应该添加以下内容, 但我不知道如何... (通过自定义扩展名,我显然可以直接在“新闻”中添加它)
'ctrl' => [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource'
],
Did you try just to override it in the TCA array inside your Overrides/tx_news_domain_model_tag.php like this? 您是否只是尝试像这样在Overrides / tx_news_domain_model_tag.php中的TCA数组中覆盖它?
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['languageField'] = 'sys_language_uid';
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['transOrigPointerField'] = 'l10n_parent';
$GLOBALS['TCA']['tx_news_domain_model_tag']['ctrl']['transOrigDiffSourceField'] = 'l10n_diffsource';
... just one small addition. ...只是一小部分。 To get the option "All" in the language selector you have to change the array sys_language_uid in Configuration/TCA/Overrides/tx_news_domain_model_tag.php like this ...
要在语言选择器中获得选项“全部”,您必须像这样在Configuration / TCA / Overrides / tx_news_domain_model_tag.php中更改sys_language_uid数组。
'sys_language_uid' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'items' => [
[
'LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages',
-1,
'flags-multiple'
],
],
'default' => 0,
],
],
... ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.