[英]TYPO3 Add new tab to page properties
I've wasted a full day trying to achieve this : what i want to do is to add a new tab (lets call it extralinks) to the page properties. 我浪费了整整一天的时间来尝试实现这一目标:我想做的是向页面属性添加一个新标签(让我们称之为附加链接)。 and this tab will contain IRRE item to add links to every page so i created a new table :
并且此选项卡将包含IRRE项目以向每个页面添加链接,因此我创建了一个新表:
CREATE TABLE links(
uid int(11) NOT NULL auto_increment,
link varchar(255) DEFAULT '' NOT NULL,
PRIMARY KEY (uid)
);
and then i added a new file to TCA/Overrides/links.php 然后我将新文件添加到TCA / Overrides / links.php
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
$GLOBALS['TCA']['links'] = array(
'ctrl' => array(
'label' => 'links',
'title' => 'extralinks',
),
'interface' => '',
'columns' => array(
'link' => array(
'label' => 'extralinks',
'exclude' => true,
'config' => array(
'type' => 'input',
'size' => 50,
'max' => 255,
'eval' => 'trim'
)
)
),
'types' => [
'0' => [
'showitem' => '
--div--;;LLL:extralinks,
link
'
]
],
'palettes' => 'extralinks'
);
$linksColumns = array(
'extralinks' => array(
'exclude' => true,
'label' => 'extralinks',
'config' => array(
'type' => 'inline',
'foreign_table' => 'links',
'maxitems' => 30,
'appearance' => [
'collapseAll' => 1,
'expandSingle' => 1,
],
)
)
);
now in the same file at the end i need to add this to have tables so i make the following: 现在在最后的同一个文件中,我需要添加此文件以具有表,因此需要进行以下操作:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', '--div--;Extra links,extralinks;;;;1-1-1', '');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $linksColumns);
when i make this the new tab is there with the new item but when i try to add a link i will get an error which says extralinks doesnt is not a column in pages table -which is understandable- 当我进行此操作时,新选项卡将包含新项,但是当我尝试添加链接时,我会收到一条错误消息,提示Extralinks不是页面表中的列-这是可以理解的-
so when i try this 所以当我尝试这个
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('links', '--div--;Extra links,extralinks;;;;1-1-1', '');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('links', $linksColumns);
now i dont even see the tab neither the item.... how can i achieve this ? 现在我什至都看不到选项卡,也没有项目...。我如何实现这一目标?
ps PS
First of all, as @Heinz Schilling says, you have to put the fields definition into TCA/Overrides/pages.php
. 首先,正如@Heinz Schilling所说,您必须将字段定义放入
TCA/Overrides/pages.php
。
You must also put an "counter"-field to your pages table, so that TYPO3 knows you have irre elements inside this page. 您还必须在页面表中放置一个“ counter”字段,以便TYPO3知道您在此页面中有不受欢迎的元素。
In your ext_tables.sql
you have to put following: 在您的
ext_tables.sql
您必须输入以下内容:
CREATE TABLE pages (
extralinks int(11) unsigned DEFAULT '0' NOT NULL,
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.