TYPO3 Extension don't get Records - typo3

I had create an extension, like this Tutorial https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/AddingYourOwnContentElements/Index.html
In my Fluid-Template I get only:
array(2 items)
data => array(105 items)
current => NULL
"data" have all fields of tt_content. I have also a field "Pages", where I can say from which General Storage the datasets come from. But I cannot get the Records push to the Fluid-Template. On the DataProcessor I can't use the Repository and my Controller isn't used.
What do I wrong?

Related

Is it possible to disable translation for a TYPO3 TCA record

Could anybody help me to sort out this issue?
I want to disable the translation for a table. So that extbase will get all the records without considering the language uid. (Setting -1 (ALL) currently fix)
Ideally I need to force sys_language_uid = -1 (ALL) For a Inline reference records. The parent record always has translations and the inline records dont have translations. Is there any standard way to force this?.
I've added 'l10n_mode' => 'exclude', to the parent TCA against the referenced table column. So that the referenced TCA inline fields wont be shown against the parent TCA record during the localization view of the parent TCA record.

TYPO3: How to check if a record is new or just a copy

I implemented two hooks (processDatamap_afterDatabaseOperations and processDatamap_postProcessFieldArray) to manipulate any record after saving.
My Question is:
Every time I copy or create a record I enter the hooks and get a parameter "status" which is always "new" no matter if the record is actually new or just a copy of an existing record.
It seems like TYPO3 handles copies as new records.
How can I check if a record is actually a copy or a new record?
I am currently working with TYPO3 Version 8.7.9.
You can use the t3_origuid.
It should be added to your extbase domain model.
See here.
After handling the "copy" command the id of the original record will be copied into this field.
So in the hooks:
processDatamap_preProcessFieldArray or processDatamap_postProcessFieldArray you can access to it.
Like:
if(isset($fieldArray['t3_origuid']) {
<your_code>
}

n-n relationships for multiple content types

I'm working on a project based on Laravel 5.3 and Backpack CRUD. My project has about 8 different content types (news, page, portfolio, events, team, video, gallery, jobs).
I need to be able to add tags to every content type (n-n), and every content type has its own specific tags, so tags are NOT shared between the content types.
If I want to use the select_multiple or select2_multiple field type, I would need 8 tables for the content itself, 8 pivot tables, and 8 tables for the tags(!).
Obviously I would like to have just one table for the tags, but if I use the select_multiple or select2_multiple field type, I get all tags in the edit-form of every content type.
So, my question is: Is there an elegant way to filter the results of the select_multiple or select2_multiple field type?
I have created a simple schema with two content types:
http://dbdesigner.net/designer/schema/60412
In this example I want to be able to filter the tag list on content_type_id, when I'm editing the content of news or page. So I just want to see the news tags in the news-edit form, and just the page tags, in the page-edit form.
Or maybe I should just use the select_multiple field type as intended, and accept the 8 tag tables(?)
Any help or advice would be greatly appreciated.
I think a clean way would be to:
create different models for each tag use, so NewsTag, PageTag, PortfolioTag etc. that would only extend the Tag model and use a global scope to filter the results after content_type_id;
use backpack select2_multiple fields with NewsTag, PageTag, PortfolioTag etc; anything you set on the Tag model will be used (including the table attribute, mutators, accessors, etc);
Cheers!

TYPO3 tt_content structure: t3_origuid vs l18n_parent

I had to import a few posts from one TYPO3 site into another, which lead into some exploring of the DB structure. A specific question arose:
In localised content elements (tt_content entries with sys_language_uid = 1), the fields t3_origuid and l18n_parent are redundantly filled. l18n_parent is required for the backend localisation view to work.
Do they always have the same value? Or is there a use case where the values of the fields can differ?
l10n_parent / l18n_parent
The field configured in TCA as transOrigPointerField (usually l10n_parent or l18n_parent) is used for localization.
It always contains an id of the record in the default language (even if the record was translated from a record in non-default language), see https://docs.typo3.org/typo3cms/TCAReference/singlehtml/#transorigpointerfield
t3_origuid
The field configured in TCA as origUid (usually t3_origuid) is filled when record is copied or translated, and contains an id of the source record, see https://docs.typo3.org/typo3cms/TCAReference/singlehtml/#origuid
The fields will have the same value in some cases (e.g. translating a record from default language), but in other will have different value. E.g. when copying a record on the same page t3_origuid will be different than the l10n_parent.
To allow localization it is required to have transOrigPointerField (l10n_parent). Having origUid (t3_origuid) field is not hard requirement but a good practice as as some additional features may require it to work. Especially in newer versions of TYPO3. For example the Translation Wizard is currently using t3_origuid field.
l10n_source (since TYPO3 8.6)
Since TYPO3 8.6 a new database field l10n_source for tt_content table has been introduced together with a new TCA ctrl configuration translationSource. The translationSource field contains an uid of the record used as a translation source, no matter whether the record was translated in the free or connected mode.
see more in the documentation on l10n_source field
Those fields can have different values.
t3_origuid is a generic field pointing to a record from which the current one was derived in some way. For example by copying or localizing it. Here is some documentation for it.
The field l18n_parent is reserved for localization purposes.
Just as a addition to Jost's post:
To determine which field you should use check the value of:
$TCA['tx_yourtable']['ctrl']['transOrigPointerField']
ie. for tt_content it's:
$TCA['tt_content']['ctrl']['transOrigPointerField'] = 'l18n_parent';

Make records "Non-Editable" after certain approving in TCA TYPO3 backend forms.

I have an extension called calendar and it contains a record event. For an event to be displayed on the Front End it has be approved by the admin. But once the admin has approved/rejected it, the record should no longer be editable from the backend.
I want to do something like this :
TcaEvent.php
if ($currentRecord_Permission=='Accept' or $currentRecord_Permission=='Reject')
# Make the current record non-editable
else #make the current record editable
Will the $TCA array contain the details of the current record being edited? If so, I can use it to achieve the above mentioned.
Try to use 'editlock'. This is exactly what you need.
Field name, which – if set – will prevent all editing of the record
for non-admin users.The field should be configured as a checkbox type.
Non-admins could be allowed to edit the checkbox but if they set it,
they will effectively lock the record so they cannot edit it again –
and they need an Admin-user to remove the lock.Note that this flag is
cleared when a new copy or version of the record is created.This
feature is used on the pages table, where it also prevents editing of
records on that page (except other pages)! Also, no new records
(including pages) can be created on the page.
So all you have to do is to set this field to TRUE after admin will approve the record. Or even admin can set that field if the approve means he enter to edit the BE record anyway.
Read more here:
http://typo3.org/documentation/document-library/core-documentation/doc_core_tca/4.7.1/view/1/3/
Find 'editlock'.
Basically you have to define in your TCA waht field in table will be an editlock field like this:
$TCA['tx_address_domain_model_item'] = array(
'ctrl' => array(
'title' => 'Title'
'editlock' => 'editlock',
...
The $TCA is a configuration array and does not contain any data of any records. It just holds the configuration of all fields that TYPO3 uses. There is also not a field which prevents a record from beeing edited except an admin. To achive this, you can create a second page which holds approved records and make this page invisible for non admin users via the permission module. Just set the owner of the page to user admin and group admin.