i can not create a table in kafka ksql - apache-kafka

this is my sql,i don't know what's wrong
CREATE TABLE memo_src (
'id' VARCHAR PRIMARY KEY,
'title' VARCHAR,
'cover_image' VARCHAR
) WITH (
KAFKA_TOPIC = 'memo.memorandum.memorandum_info',
VALUE_FORMAT='AVRO'
);
Then prompt me as follows
extraneous input ''id'' expecting {'EMIT', 'CHANGES', 'INTEGER', 'DATE', 'TIME', 'TIMESTAMP', 'INTERVAL', 'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', 'SECOND', 'ZONE', 'PARTITION', 'STRUCT', 'EXPLAIN', 'ANALYZE', 'TYPE', 'TYPES', 'SHOW', 'TABLES', 'COLUMNS', 'COLUMN', 'PARTITIONS', 'FUNCTIONS', 'FUNCTION', 'ARRAY', 'MAP', 'SET', 'RESET', 'SESSION', 'KEY', 'SINK', 'SOURCE', 'IF', IDENTIFIER, DIGIT_IDENTIFIER, QUOTED_IDENTIFIER, BACKQUOTED_IDENTIFIER}
Statement: CREATE TABLE memo_src (
'id' VARCHAR PRIMARY KEY,
'title' VARCHAR,
'cover_image' VARCHAR
) WITH (
KAFKA_TOPIC = 'memo.memorandum.memorandum_info',
VALUE_FORMAT='AVRO'
);

your id, title and cover_image are not supposed to be in quotation marks. That's why the compiler states it did not expect the token 'id'.

Related

TYPO3 9 Extbase EXT originalResource of FileReference is always NULL. Why?

I'm developing my own Extension. In this Extension it is possible to add Images to a content element. In the Backend viewing everything is working fine. In the DB the reference of sys_file to my database table via sys_file_reference looks good too.
But when I place <f:debug>{_all}</f:debug> in the template, the originalResource of the File is NULL.
Can somone tell me, what I'm missing?
Here is some code of my Extension:
ext_tables.sql
#
# Table structure for table 'tx_redspaceproduct_domain_model_product'
#
CREATE TABLE tx_redspaceproduct_domain_model_product (
uid int(11) unsigned NOT NULL AUTO_INCREMENT,
pid int(11) unsigned DEFAULT '0' NOT NULL,
number int(5) DEFAULT '0' NOT NULL,
name varchar(255) DEFAULT '' NOT NULL,
slug varchar(255) DEFAULT '' NOT NULL,
subname varchar(255) DEFAULT '' NOT NULL,
image int(11) unsigned NOT NULL default '0',
flyer int(11) unsigned NOT NULL default '0',
featureteaser text DEFAULT '',
description text DEFAULT '',
specifications text DEFAULT '',
features text DEFAULT '',
accuracy text DEFAULT '',
category int(11) unsigned DEFAULT '0' NOT NULL,
type int(11) unsigned DEFAULT '0' NOT NULL,
sibling int(11) unsigned DEFAULT '0' NOT NULL,
related int(11) unsigned DEFAULT '0' NOT NULL,
accessory int(11) unsigned DEFAULT '0' NOT NULL,
package int(11) unsigned DEFAULT '0' NOT NULL,
download int(11) unsigned DEFAULT '0' NOT NULL,
hidden int(1) unsigned DEFAULT '0' NOT NULL,
deleted int(1) unsigned DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
FOREIGN KEY (category) REFERENCES tx_redspaceproduct_domain_model_category(uid),
FOREIGN KEY (type) REFERENCES tx_redspaceproduct_domain_model_type(uid)
);
tx_redspaceproduct_domain_model_product.php
'image' => [
'exclude' => true,
'label' => 'LLL:EXT:redspace_product/Resources/Private/Language/locallang_db.xlf:tx_redspaceproduct_domain_model_product.image',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'image',
[
'appearance' => [
'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference'
],
'overrideChildTca' => [
'types' => [
'foreign_types' => [
'0' => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
]
],
],
],
'maxitems' => 99
],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
],
Product.php
<?php
namespace REDSPACE\RedspaceProduct\Domain\Model;
use \TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use \TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use \TYPO3\CMS\Extbase\Domain\Model\FileReference;
/***
*
* This file is part of the "Redspace Product" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2019 Robin Probst <web#redspace.ch>, REDSPACE AG
*
***/
/**
* Product
*/
class Product extends AbstractEntity
{
/**
* image
*
* #var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<TYPO3\CMS\Extbase\Domain\Model\FileReference>
* #TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
*/
protected $image = null;
/**
* __construct
*/
public function __construct()
{
$this->initStorageObjects();
}
/**
* Initializes all ObjectStorage properties
*
* #return void
*/
protected function initStorageObjects()
{
$this->file = new ObjectStorage();
}
/**
* Returns the image
*
* #return ObjectStorage<FileReference> $image
*/
public function getImage()
{
return $this->image;
}
/**
* Sets the image
*
* #param ObjectStorage<FileReference> $image
* #return void
*/
public function setImage(ObjectStorage $image)
{
$this->image = $image;
}
}
ProductRepository.php:
<?php
namespace REDSPACE\RedspaceProduct\Domain\Repository;
use \TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
/***
*
* This file is part of the "Redspace Product" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2019 Robin Probst <web#redspace.ch>, REDSPACE AG
*
***/
/**
* The repository for Products
*/
class ProductRepository extends Repository
{
protected $tableName = 'tx_redspaceproduct_domain_model_product';
public function getProductOfCategory($category) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)- >getQueryBuilderForTable($this->tableName);
$statement = $queryBuilder
->select('*')
->from($this->tableName)
->where($queryBuilder->expr()->like('category', $category))
->execute();
$rows = $statement->fetchAll();
return $rows;
}
public function getFlyerIdentifier($uid) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)- >getQueryBuilderForTable($this->tableName);
$statement = $queryBuilder
->select('identifier')
->from('sys_file')
->leftJoin('sys_file','sys_file_reference','sys_file_reference',$queryBuilder->expr()->eq('sys_file_reference.uid_local', $queryBuilder->quoteIdentifier('sys_file.uid')))
->where($queryBuilder->expr()->eq('sys_file_reference.uid_foreign', $uid))
->andWhere($queryBuilder->expr()->eq('extension', '"pdf"'))
->execute();
$rows = $statement->fetchAll();
return $rows;
}
}
This is the Output of f:debug:
Deprecation Log:
you can access the originalResource in the debug-ViewHelper if you call it directly:
<f:debug>{image.originalResource}</f:debug>
Reason: https://forge.typo3.org/issues/66727#note-2

Cannot create stream with KSQL

I am trying to create a stream using ksql.
ksql> CREATE STREAM fakeData22 (Id VARCHAR, category VARCHAR, timeStamp VARCHAR, deviceID INTEGER, properties MAP<VARCHAR, VARCHAR>) WITH (KAFKA_TOPIC='fake-data-19', VALUE_FORMAT='JSON');
I get the following output. Am i missing something?
line 1:94: extraneous input 'properties' expecting {'ADD', 'APPROXIMATE', 'AT', 'CONFIDENCE', 'NO', 'SUBSTRING', 'POSITION', 'TINYINT', 'SMALLINT', 'INTEGER', 'DATE', 'TIME', 'TIMESTAMP', 'INTERVAL', 'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', 'SECOND', 'ZONE', 'OVER', 'PARTITION', 'RANGE', 'ROWS', 'PRECEDING', 'FOLLOWING', 'CURRENT', 'ROW', 'VIEW', 'REPLACE', 'GRANT', 'REVOKE', 'PRIVILEGES', 'PUBLIC', 'OPTION', 'EXPLAIN', 'ANALYZE', 'FORMAT', 'TYPE', 'TEXT', 'GRAPHVIZ', 'LOGICAL', 'DISTRIBUTED', 'TRY', 'SHOW', 'TABLES', 'SCHEMAS', 'CATALOGS', 'COLUMNS', 'COLUMN', 'USE', 'PARTITIONS', 'FUNCTIONS', 'TO', 'SYSTEM', 'BERNOULLI', 'POISSONIZED', 'TABLESAMPLE', 'RESCALED', 'ARRAY', 'MAP', 'SET', 'RESET', 'SESSION', 'DATA', 'START', 'TRANSACTION', 'COMMIT', 'ROLLBACK', 'WORK', 'ISOLATION', 'LEVEL', 'SERIALIZABLE', 'REPEATABLE', 'COMMITTED', 'UNCOMMITTED', 'READ', 'WRITE', 'ONLY', 'CALL', 'NFD', 'NFC', 'NFKD', 'NFKC', 'IF', 'NULLIF', 'COALESCE', IDENTIFIER, DIGIT_IDENTIFIER, QUOTED_IDENTIFIER, BACKQUOTED_IDENTIFIER}
Caused by: line 1:94: extraneous input 'properties' expecting {'ADD', 'APPROXIMATE', 'AT', 'CONFIDENCE', 'NO', 'SUBSTRING', 'POSITION', 'TINYINT', 'SMALLINT', 'INTEGER', 'DATE', 'TIME', 'TIMESTAMP', 'INTERVAL', 'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', 'SECOND', 'ZONE', 'OVER', 'PARTITION', 'RANGE', 'ROWS', 'PRECEDING', 'FOLLOWING', 'CURRENT', 'ROW', 'VIEW', 'REPLACE', 'GRANT', 'REVOKE', 'PRIVILEGES', 'PUBLIC', 'OPTION', 'EXPLAIN', 'ANALYZE', 'FORMAT', 'TYPE', 'TEXT', 'GRAPHVIZ', 'LOGICAL', 'DISTRIBUTED', 'TRY', 'SHOW', 'TABLES', 'SCHEMAS', 'CATALOGS', 'COLUMNS', 'COLUMN', 'USE', 'PARTITIONS', 'FUNCTIONS', 'TO', 'SYSTEM', 'BERNOULLI', 'POISSONIZED', 'TABLESAMPLE', 'RESCALED', 'ARRAY', 'MAP', 'SET', 'RESET', 'SESSION', 'DATA', 'START', 'TRANSACTION', 'COMMIT', 'ROLLBACK', 'WORK', 'ISOLATION', 'LEVEL', 'SERIALIZABLE', 'REPEATABLE', 'COMMITTED', 'UNCOMMITTED', 'READ', 'WRITE', 'ONLY', 'CALL', 'NFD', 'NFC', 'NFKD', 'NFKC', 'IF', 'NULLIF', 'COALESCE', IDENTIFIER, DIGIT_IDENTIFIER, QUOTED_IDENTIFIER, BACKQUOTED_IDENTIFIER}
Because KSQL doesn't support backtick escaping.
The actually working workaround if table columns are declared with backtick escaping and being uppercase :
CREATE STREAM fakeData22 \
(Id VARCHAR, category VARCHAR, timeStamp VARCHAR, deviceID INTEGER, \
`PROPERTIES` MAP<VARCHAR, VARCHAR>) \
WITH (KAFKA_TOPIC='fake-data-19', \
VALUE_FORMAT='JSON');
and query like below.
ksql> select `PROPERTIES` from fakeData22;
Related KSQL Github issue : Support escaping identifier names. #677
I think properties must be a reserved word in KSQL. I've added this to an issue on the KSQL project for us to track, but in the meantime please try enclosing properties in backticks:
CREATE STREAM fakeData22 \
(Id VARCHAR, category VARCHAR, timeStamp VARCHAR, deviceID INTEGER, \
`properties` MAP<VARCHAR, VARCHAR>) \
WITH (KAFKA_TOPIC='fake-data-19', \
VALUE_FORMAT='JSON');

Getting unnecessary stop words from text in matlab?

stopwords_cellstring={'a','s', 'about', 'above', 'above', 'across', 'after', ...
'afterwards', 'again', 'against', 'all', 'almost', 'alone', 'along', ...
'already', 'also','although','always','am','among', 'amongst', 'amoungst', ...
'amount', 'an', 'and', 'another', 'any','anyhow','anyone','anything','anyway', ...
'anywhere', 'are', 'around', 'as', 'at', 'back','be','became', 'because','become',...
'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'below',...
'beside', 'besides', 'between', 'beyond', 'bill','all','When', 'both', 'bottom','but', 'by',...
'call', 'can', 'cannot', 'cant', 'co', 'con', 'could', 'couldnt', 'cry', 'de',...
'describe', 'detail', 'do', 'done', 'down', 'due', 'during', 'each', 'eg', 'eight',...
'either', 'eleven','else', 'elsewhere', 'empty', 'enough', 'etc', 'even', 'ever', ...
'every', 'everyone', 'everything', 'everywhere', 'except', 'few', 'fifteen', 'fify',...
'fill', 'find', 'fire', 'first', 'five', 'for', 'former', 'formerly', 'forty', 'found',...
'four', 'from', 'front', 'full', 'further', 'get', 'give', 'go', 'had', 'has', 'hasnt',...
'have', 'he', 'hence', 'her', 'here', 'hereafter', 'hereby', 'herein', 'hereupon', ...
'hers', 'herself', 'him', 'himself', 'his', 'how', 'however', 'hundred', 'ie', 'if',...
'in', 'inc', 'indeed', 'interest', 'into', 'is', 'it', 'its', 'itself', 'keep', 'last',...
'latter', 'latterly', 'least', 'less', 'ltd', 'made', 'many', 'may', 'me', 'meanwhile',...
'might', 'mill', 'mine', 'more', 'moreover', 'most', 'mostly', 'move', 'much', 'must',...
'my', 'myself', 'name', 'namely', 'neither', 'never', 'nevertheless', 'next', 'nine',...
'no', 'nobody', 'none', 'noone', 'nor', 'not', 'nothing', 'now', 'nowhere', 'of', 'off',...
'often', 'on', 'once', 'one', 'only', 'onto', 'or', 'other', 'others', 'otherwise',...
'our', 'ours', 'ourselves', 'out', 'over', 'own','part', 'per', 'perhaps', 'please',...
'put', 'rather', 're', 'same', 'see', 'seem', 'seemed', 'seeming', 'seems', 'serious',...
'several', 'she', 'should', 'show', 'side', 'since', 'sincere', 'six', 'sixty', 'so',...
'some', 'somehow', 'someone', 'something', 'sometime', 'sometimes', 'somewhere', ...
'still', 'such', 'system', 'take', 'ten', 'than', 'that', 'the', 'their', 'them',...
'themselves', 'then', 'thence', 'there', 'thereafter', 'thereby', 'therefore', ...
'therein', 'thereupon', 'these', 'they', 'thickv', 'thin', 'third', 'this', 'those',...
'though', 'three', 'through', 'throughout', 'thru', 'thus', 'to', 'together', 'too',...
'top', 'toward', 'towards', 'twelve', 'twenty', 'two', 'un', 'under', 'until', 'up',...
'upon', 'us', 'very', 'via', 'was', 'we','all', 'well', 'were','uses','way','went', 'what', 'whatever', 'when',...
'whence', 'whenever', 'where', 'whereafter', 'whereas', 'whereby', 'wherein',...
'whereupon', 'wherever', 'whether', 'which', 'while', 'whither', 'who', 'whoever',...
'whole','When', 'whom', 'whose','saw', 'why', 'will', 'with', 'within', 'without', 'would', 'yet',...
'you', 'your', 'yours', 'yourself', 'yourselves', 'the'};
above are the stop words that i am using to process a text file and removing them but there are some words which are not still eliminated listed as follows:
[3] 'The'
[6] 'â'
[5] 's'
can anyone help me how to eliminate these words the code i'm using is as follows
str1 = F
split1 = regexp(str1,'\s','Split');
out_str1 = strjoin(split1(~ismember(split1,stopwords_cellstring)),' ')
C = regexp(out_str1, '<s>|\w*|</s>', 'match');
Just concentrating on word filtering and if willing to be case insensitive, using ~ismember will not work. Here is a solution to filter stopwords while being not case sensitive:
str1 = F
split1 = regexp(str1,'\s','Split');
%%%%
logic = arrayfun(#(word)any(strcmpi(word, stopwords_cellstring)), split1);
out_str1 = strjoin(split1(~logic), ' ');
%%%%
C = regexp(out_str1, '<s>|\w*|</s>', 'match');
How it works:
I have replaced ismember test with arrayfun. For each word in split1, the arrayfun checks if this word match any of the words in stopwords_cellstring using strcmpi (case insensitive).
NB1: For s it is not part of your stop list.
NB2: For â, I don't know if there's a quick solution to convert it to a (i.e without accentuation) ... easy solution would be to add it to your list unless it is included in more complex word like âmer for instance ... in this last case I would advice you to prefilter str1 with str1 = strrep(str1, 'â', 'a').

Removing stop words from single string

My query is string = 'Alligator in water' where in is a stop word. How can I remove it so that I get stop_remove = 'Alligator water' as output. I have tried it with ismember but it returns integer value for matching word, I want to get the remaining words as output.
in is just an example, I'd like to remove all possible stop words.
A slightly more elegant way than Luis Mendo's solution is to use regexprep that does exactly what you want
>> result = regexprep( 'Alligator in water', 'in\s*', '' ); % replace with an empty string
result =
Alligator water
If you have several stop words you can simply add them to the pattern (in this example I consider 'in' and 'near' as stop words):
>> result = regexprep( 'Alligator in water near land', {'in\s*','near\s*'}, '' )
result =
Alligator water land
Use this for removing all stop-words.
Code
% Source of stopwords- http://norm.al/2009/04/14/list-of-english-stop-words/
stopwords_cellstring={'a', 'about', 'above', 'above', 'across', 'after', ...
'afterwards', 'again', 'against', 'all', 'almost', 'alone', 'along', ...
'already', 'also','although','always','am','among', 'amongst', 'amoungst', ...
'amount', 'an', 'and', 'another', 'any','anyhow','anyone','anything','anyway', ...
'anywhere', 'are', 'around', 'as', 'at', 'back','be','became', 'because','become',...
'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'below',...
'beside', 'besides', 'between', 'beyond', 'bill', 'both', 'bottom','but', 'by',...
'call', 'can', 'cannot', 'cant', 'co', 'con', 'could', 'couldnt', 'cry', 'de',...
'describe', 'detail', 'do', 'done', 'down', 'due', 'during', 'each', 'eg', 'eight',...
'either', 'eleven','else', 'elsewhere', 'empty', 'enough', 'etc', 'even', 'ever', ...
'every', 'everyone', 'everything', 'everywhere', 'except', 'few', 'fifteen', 'fify',...
'fill', 'find', 'fire', 'first', 'five', 'for', 'former', 'formerly', 'forty', 'found',...
'four', 'from', 'front', 'full', 'further', 'get', 'give', 'go', 'had', 'has', 'hasnt',...
'have', 'he', 'hence', 'her', 'here', 'hereafter', 'hereby', 'herein', 'hereupon', ...
'hers', 'herself', 'him', 'himself', 'his', 'how', 'however', 'hundred', 'ie', 'if',...
'in', 'inc', 'indeed', 'interest', 'into', 'is', 'it', 'its', 'itself', 'keep', 'last',...
'latter', 'latterly', 'least', 'less', 'ltd', 'made', 'many', 'may', 'me', 'meanwhile',...
'might', 'mill', 'mine', 'more', 'moreover', 'most', 'mostly', 'move', 'much', 'must',...
'my', 'myself', 'name', 'namely', 'neither', 'never', 'nevertheless', 'next', 'nine',...
'no', 'nobody', 'none', 'noone', 'nor', 'not', 'nothing', 'now', 'nowhere', 'of', 'off',...
'often', 'on', 'once', 'one', 'only', 'onto', 'or', 'other', 'others', 'otherwise',...
'our', 'ours', 'ourselves', 'out', 'over', 'own','part', 'per', 'perhaps', 'please',...
'put', 'rather', 're', 'same', 'see', 'seem', 'seemed', 'seeming', 'seems', 'serious',...
'several', 'she', 'should', 'show', 'side', 'since', 'sincere', 'six', 'sixty', 'so',...
'some', 'somehow', 'someone', 'something', 'sometime', 'sometimes', 'somewhere', ...
'still', 'such', 'system', 'take', 'ten', 'than', 'that', 'the', 'their', 'them',...
'themselves', 'then', 'thence', 'there', 'thereafter', 'thereby', 'therefore', ...
'therein', 'thereupon', 'these', 'they', 'thickv', 'thin', 'third', 'this', 'those',...
'though', 'three', 'through', 'throughout', 'thru', 'thus', 'to', 'together', 'too',...
'top', 'toward', 'towards', 'twelve', 'twenty', 'two', 'un', 'under', 'until', 'up',...
'upon', 'us', 'very', 'via', 'was', 'we', 'well', 'were', 'what', 'whatever', 'when',...
'whence', 'whenever', 'where', 'whereafter', 'whereas', 'whereby', 'wherein',...
'whereupon', 'wherever', 'whether', 'which', 'while', 'whither', 'who', 'whoever',...
'whole', 'whom', 'whose', 'why', 'will', 'with', 'within', 'without', 'would', 'yet',...
'you', 'your', 'yours', 'yourself', 'yourselves', 'the'};
str1 = 'Alligator in water of the pool'
split1 = regexp(str1,'\s','Split');
out_str1 = strjoin(split1(~ismember(split1,stopwords_cellstring)),' ')
Output
str1 =
Alligator in water of the pool
out_str1 =
Alligator water pool
NOTE: This code uses strjoin from Mathworks File-exchange.
Use regexp:
string = 'Alligator in water'; %// data string
result = regexp(string, 'in\s*', 'split'); %// split according to stop word
result = [result{:}]; %// join remaining pieces

Add marker to tt_news which saves the link to another page

I want that the user can specify a link to a page. Therefore an group is used. The example is based on the field "related". Since the rest is structured for more than entry, also the user should be able to set more than one link. A reverse query is not needed.
This is how I do it:
Here I load the input field "link":
$TCA['tt_news'] = Array (
'ctrl' => $TCA['tt_news']['ctrl'],
'interface' => Array (
'showRecordFieldList' => 'title,hidden,datetime,starttime,archivedate,category,author,author_email,short,image,imagecaption,links,related,news_files,link'
),
Here I define the field "link"
'link' => Array (
'label' => 'Link to another page',
'config' => Array (
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'tt_news,pages',
'MM' => 'tt_news_link_mm',
'size' => '3',
'autoSizeMax' => 10,
'maxitems' => '200',
'minitems' => '0',
'show_thumbs' => '1',
'wizards' => array(
'suggest' => array(
'type' => 'suggest'
)
)
)
),
I used the field "related" as sample.
Here I define the position in the backend:
'types' => Array (
'0' => Array('showitem' =>
'hidden, type;;;;1-1-1,title;;;;2-2-2,short,bodytext;;2;richtext:rte_transform[flag=rte_enabled|mode=ts];4-4-4,
--div--;LLL:EXT:tt_news/locallang_tca.xml:tt_news.tabs.special, datetime;;;;2-2-2,archivedate,author;;3;; ;;;;2-2-2,
keywords;;;;2-2-2,sys_language_uid;;1;;3-3-3,
--div--;LLL:EXT:tt_news/locallang_tca.xml:tt_news.tabs.media, image;;;;1-1-1,imagecaption;;5;;,links;;;;2-2-2,news_files;;;;4-4-4,link;;;;3-3-3,
--div--;LLL:EXT:tt_news/locallang_tca.xml:tt_news.tabs.catAndRels, category;;;;3-3-3,related;;;;3-3-3,
--div--;LLL:EXT:tt_news/locallang_tca.xml:tt_news.tabs.access, starttime,endtime,fe_group,editlock,
--div--;LLL:EXT:tt_news/locallang_tca.xml:tt_news.tabs.extended,
'),
Now the field is shown as expected. I can choose a page and it appears in the selection list. In the field in the table tt_news the value only changes from 0 to 1. Also in the table tt_news_related_mm there is now an entry. I have reached this by using a separate table.
CREATE TABLE `tt_news_link_mm` (
`uid_local` int(11) NOT NULL default '0',
`uid_foreign` int(11) NOT NULL default '0',
`sorting` int(11) NOT NULL default '0',
`tablenames` varchar(255) NOT NULL default '',
KEY `uid_local` (`uid_local`),
KEY `uid_foreign` (`uid_foreign`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Only one thing is missing: How can I translate an page ID into a speaking URL?
Now I managed it with the help from cascaval:
$typolink_conf = array(
"title" => $title,
"ATagParams" =>'',
"no_cache" => 0,
"parameter" => $data['uid'],
"useCacheHash" => 1
);
$link = $this->cObj->typolink('linkname', $typolink_conf);