[TYPO3-dev] Workspaces, languages, where, enableFields...
Sonja Scholz
ss at cabag.ch
Thu Jul 3 12:20:29 CEST 2008
Ernesto Baschny [cron IT] schrieb:
> Sonja Scholz wrote: on 03.07.2008 10:08:
>
>> We would like to select records from a table with certain criterias.
>> The records should be translated by language overlay and the workspace
>> preview should also be considered. Additionally of course the
>> enableFields should be taken care of.
>>
>> We could not find any satisfying solution. Language and enableFields
>> is easy, but the whole workspace thing is nearly impossible to do it
>> the right way.
>>
>> There should be really ONE simple snippet/example which includes
>> everything which should be considered.
>>
>> There are nearly no extensions which do workspace preview, because it
>> is so hard to implement.
>>
>> It would also be nice to have a general function for doing that:
>> http://bugs.typo3.org/view.php?id=8889
>>
>> It would be also great if one could JOIN multiple tables and still the
>> workspace would be recognized. Imagine you have some records which
>> have a (real) MM relation to another table (categories) and you want
>> to select all records which are in category B, but translated and
>> workspace preview...
>>
>> If you want to have extension developer implementing workspace, it has
>> to be as easy as possible :-)
>>
>> Does anybody have a usable example?
>
> Well, versionOL() should be all you need for workspace support if you
> are selecting records based on an uid (single-view) or a pid:
>
> $row = get your records as you do, using ->enableFields
> ...
> $GLOBALS['TSFE']->sys_page->versionOL($table, $row);
> $GLOBALS['TSFE']->sys_page->fixVersioningPid($table,$row);
> if ($GLOBALS['TSFE']->sys_language_content > 0) {
> $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay(
> $table,
> $row,
> $GLOBALS['TSFE']->sys_language_content,
> $GLOBALS['TSFE']->sys_language_contentOL
> );
> }
>
> I found it important to do the versionOL before doing the recordOverlay
> for translations.
>
> Ok, more complex stuff might be required in special cases. Also take a
> look at tt_news, because it probably contains all stuff needed for
> workspaces, although it is a bit confusing to find.
>
> About the "join" problem, yea, that will probably need more "brain
> activity" than I can handle at the moment. :)
>
> Cheers,
> Ernesto
Hello Ernesto
thank you for your fast answer with the example.
I tried to use it in my extension, but for now it doesn't work. I don't
get the workspace version of the records. I get only the same records as
in the live modus.
$dbRes = $GLOBALS['TYPO3_DB']->exec_SELECTQuery(
'DISTINCT table_1.*,
table_2.uid as category_uid,
table_2.name as category_name',
'table_1, table_2',
$where.' AND table_1.sys_language_uid = 0
AND table_1.category = table_2.uid
AND table_2.sys_language_uid = table_1.sys_language_uid
'.$this->cObj->enableFields('table_1').'
'.$this->cObj->enableFields('table_2'),
'',
$order
);
// array where the article objects will be put in
$finalRecords= array();
// fetch basic data and create article objects
while($currentRecord= $GLOBALS['TYPO3_DB']->sql_fetch_assoc($dbRes)){
$GLOBALS['TSFE']->sys_page->versionOL('table_1', $currentRecord);
$GLOBALS['TSFE']->sys_page->fixVersioningPid('table_1', $currentRecord);
// check if not the default language is selected
if ($GLOBALS['TSFE']->sys_language_content > 0) {
$currentRecord= $GLOBALS['TSFE']->sys_page->getRecordOverlay(
'table_1',
$currentRecord,
$GLOBALS['TSFE']->sys_language_content,
$this->OLmode);
}
// add record to result array if it exists
if($currentRecord) {
$finalRecords[] = $currentRecord;
}
}
I tried to do a workspace preview by changing on record in the workspace
and then looking on (with the magnifying glass) the page which shows a
list of records.
Have I understood something wrong?
Kind regards,
Sonja
More information about the TYPO3-dev
mailing list