[TYPO3-dev] Help with extension development - multiple languages
Morten Hagh
morten at hagh.dk
Wed Nov 10 10:24:31 CET 2010
Hi list,
I have some problems with an extension I am working on. Its my first time
in the extension development world, so please bear with me, if my questions
is ridiculous. J
Its an extension for bricks with technical data as well as descriptions,
titles, prices, reference pictures etc. etc.
I have two tables one for technical data (tx_rtmur_bricks_data) and one for
the description and titles and so forth (tx_rtmur_bricks). I am doing it
this way because it is possible that a brick (lets call it 201) is produced
on more than one brickwork with different data. So you start with creating
the brick with title, descripton, etc. and then a data record with a field
to select which brick (with brick ID) the data belongs to, for each
brickwork.
This works almost as intended, but my problems occur with multiple
languages.
If I choose a brick in SINGLE VIEW on the default language it is shown in
the default language, but if I click on e.g. swedish in my language menu,
the brick is still shown in the default language.
I am creating a brick record with title, description etc., in my default
language which is danish and the translations in for other languages.
Because the data table is language independent, I just cant seem to get it
done correctly because it is related to the brick with a brick id.
The 201 bricks are created in danish and gets uid =1 and then I create a
data record, which is given the id 1 in the brick column, because it relates
to the brick that has uid=1.
If I now create a translation in swedish of 201 it gets uid=2, but now I
cant get the data because it relates to uid= 1. The 110n_parent column in
the swedish translation has id=1.
Heres a summary:
The data table shall not have any translation as the data is language
independent and the same data record(s) should be used on brick 201 whether
it is a danish, swedish or english translation.
My code for SINGLE VIEW:
-------
function dpSingle() {
selectConf = array();
$selectConf['selectFields'] = '*';
$selectConf['selectTable'] = 'tx_rtmur_bricks';
$selectConf['where'] = 'uid=1';
$rows =
$GLOBALS['TYPO3_DB']->exec_SELECTgetRows($selectConf['selectFields'],
$selectConf['selectTable'], 'pid='. intval($this->conf['storagePid']) .' AND
'. $selectConf['where'] . $this->cObj->enableFields('tx_rtmur_bricks'));
if ($GLOBALS['TSFE']->sys_language_content) {
$rows = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tx_rtmur_bricks',
$rows, $GLOBALS['TSFE']->sys_language_content,
$GLOBALS['TSFE']->config['config']['sys_language_overlay']);
}
if(count($rows) == 0) {
$template = $this->cObj->getSubpart($this->templateCode,
'###NO_SINGLE_ITEM###');
$content = $this->cObj->substituteMarker($template,
'###TXT_NO_SINGLE_PRODUCT###', $this->pi_getLL('no_single_product'));
} else {
$markers = array();
foreach($rows[0] as $sI => $sIvalue) {
$markers['###SINGLE_'.strtoupper($sI).'###'] =
$this->cObj->stdWrap(htmlspecialchars($sIvalue),
$this->conf['singleView.'][$sI . '_stdWrap.']);
}
$data = $GLOBALS['TYPO3_DB']->exec_SELECTquery('brickwork, brick',
'tx_rtmur_bricks_data', 'brick=1' .
$this->cObj->enableFields('tx_rtmur_bricks_data'));
$bw = array("gt" => "Gandrup Teglværk", "vt" => "Vindø Teglværk");
}
If someone can help me with the correct approach on this problem, I will be
very grateful.
More information about the TYPO3-dev
mailing list