I created an extension with the Extension Builder and inserted the model class for my countries table:
\SJBR\StaticInfoTables\Domain\Model\Country
When I save the extension the Builder warns me with
The configuration for table "static_countries" is not compatible with extbase. You have to configure it yourself if you want to map to this table (Error 606)
I tried to read the manual but I couldnt find a way how to map it in my extension. In the backend the dropdown works fine but in the Extension I only get uid from the model
If anybody is searching for this .. I finally managed or understood how to do it.
add
use SJBR\StaticInfoTables\Domain\Model\Country;
in your Domain\Model\countries.php or whatever it's called
change the default
class Countries extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
that the extension_builder generates to extend the static_info_tables model:
class Countries extends Country
Thats it. Now you get all properties from the countries table
Related
I want to override the label strings "Available Items" and "Selected Items" in a selectMultipleSideBySide form because it is too generic. I have multiple record types using this form template so I cannot change the strings globally.
I tried to change it in the TCA of my custom record type without success. I only see the label for the entire relation.
I am using TYPO3 8.7
Does anyone know an extension which accomplished this or does anyone know the config path to there?
Thanks!
Edit:
In the class typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php at line 393 I found the translation path hard-coded. So I need to inherit from this class and register it as my new selectMultipleSideBySide in the TCA.
I copied the class TYPO3.CMS/typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php to my extension in Classes/From/Element/SelectTagCloudElement.php
I adapted namespace to my extensions.
I add a use-directive of use TYPO3\CMS\Backend\Form\Element\SelectMultipleSideBySideElement;.
I adapt the translation string like in line 221 to my custom records translation xml file.
I found on https://docs.typo3.org/m/typo3/reference-coreapi/8.7/en-us/ApiOverview/FormEngine/Rendering/Index.html a snippet to register an new NodeType (the class I extended previously) using:
// Add new field type to NodeFactory
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1487112284] = [
'nodeName' => 'selectTagCloud',
'priority' => '70',
'class' => \MyVendor\CoolTagCloud\Form\Element\SelectTagCloudElement::class,
];
in ext_localconf.php
Now I can use selectTagCloud instead of selectMultipleSideBySide in the TCA.
"Dump Autoload Information" in the Install Tool
Done
import from tt_news in TYPO3 8 LTS with actual news and news_ttnewsimport is working fine. But we had some individual fields in tt_news and i want to import theese fields too in individuel fields in news.
So i made a new extension which extends news with individual fields. It is working fine: i can edit them in the backend and print content in the frontend.
Then i modified getImportData() in TTNewsNewsDataProviderService of news_ttnewsimport and added my new fields. The content of the individual fields of tt_news is fetched, i controlled it with a log-file. But the content was not written in the database ... I controlled the getter and setter in my configuration of news but all seems correct.
After some debugging i found that all commands which write the content in news are hardcoded in news/Classes/Domain/Service/NewsImportService.php:
$news->setAuthor($importItem['author']);
After adding my fields all works:
$news->setMyNewField($importItem['my_new_field']);
So my problem is fixed ... well some how: it seems dirty to change a class of an extension in order to handle individual fields.
Is there a correct possibility to make the import work with individual fields, without patching news?
Thanks!
In version 7 of tx_news i found the answer of my question ... i don't know wether it exists in older versions but in 7.1 it is possible to use a signal slot for this task:
link to the manual: Prehydrate slot
I'm writing a TYPO3 extension using TYPO3 CMS 7.6.x LTS and Extension Builder. One of my extension's tasks is to scan through the "header" and "bodytext" fields of TYPO3's tt_content table; match specific text patterns in "bodytext"; parse the found text; and put the resulting data into my extension's log table along with a label from the tt_content "header" field.
"Using Foreign Data Sources" in "Developing TYPO3 Extensions with Extbase and Fluid" at [ https://docs.typo3.org/typo3cms/ExtbaseFluidBook/6-Persistence/4-use-foreign-data-sources.html ] talks about putting data INTO tt_address using a TypoScript mapping. Instead, I'm reading data FROM tt_content, and would rather stay within PHP in the extension.
Using the graph in Foreign Key to TYPO3 Frontend User as an example, I added a second model to my extension's domain model in Extension Builder. I made a "TtContent" model, and used its "Domain object settings" to "map to existing table", its entry being "tt_content". I did NOT enter a value into the "extend using model class" field. I made a "relation" field in my Log model, and ran a wire connected from my Log:ttContent relation field to the title bar of my TtContent model. When I then clicked "Save", Extension Builder replied: "The configuration for table "tt_content" is not compatible with extbase. You have to configure it yourself if you want to map to this table (Error 606)". I don't understand this error message.
In Extension Builder, do I make a relation in my Log model to an existing external class? If so, which external class do I use? Or, do I make a model of tt_content in Extension Builder, and somehow get through that error 606? It shouldn't seem hard to do, because I want to read from an existing table already in TYPO3.
Solution: Create an Extbase model and a repository representing the existing tt_content table, then write a TypoScript property mapping.
In TYPO3 Extension Builder's domain modeller, add a model called "Content" or some name that reminds you of the tt_content table. In the "domain object settings" part of your Content model, put "tt_content" in the "map to existing table" box. Nevermind the "extend existing model class" box, because Extbase doesn't have such a class for tt_content.
Also in the domain object settings, set object type to "Entity", check the "is aggregate root" box, and uncheck the "add deleted field", "add hidden field", "add starttime/endtime fields", and "enable categorization" boxes. Setting the object type to "entity" and checking the "is aggregate root?" box causes Extension Builder to create a repository for your Content model.
Add properties to your Content model that represent the columns you want to access in the tt_content database table. In my Content model, I added only "header" and "bodytext" properties.
Note: You need not add TYPO3's uid or pid properties to the Content model. These properties have been extended from the parent \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject class.
Click "Save" in Extension Builder to save your new domain model. You will receive a message: "Warning! The configuration for table "tt_content" is not compatible with extbase. You have to configure it yourself if you want to map to this table (Error 606). Do you want to save anyway?" Yes, save anyway. Extension Builder will respond, "Success. The Extension was saved. Your Extension is not installed yet." Exit Extension Builder.
Note: If you go through several modelling iterations in Extension Builder, you may find artifacts in the extension's final code, left over from your earlier iterations. Extension Builder overwrites some of your extension areas, but leaves other areas alone. See the Extension Builder configuration reference at [ https://docs.typo3.org/typo3cms/extensions/extension_builder/Configuration/Index.html ].
Use Extbase table mapping to configure and thereby access content from the TYPO3 tt_content table. Do this configuration with TypoScript "config.tx_extbase.persistence.classes" mapping parameters in the "typo3conf/ext/yourextensionkey/ext_typoscript_setup.txt" file. Extension Builder created this file when you saved your domain model. This is the configuring mentioned in Error 606.
See the code example in "Using Foreign Data Sources" at [ https://docs.typo3.org/typo3cms/ExtbaseFluidBook/6-Persistence/4-use-foreign-data-sources.html ]. This TypoScript code example defines the mapping lines themselves. You may wish to use "config.tx_extbase" instead of "plugin.tx_myextension". The next page, "Modeling the Class Hierarchy" at [ https://docs.typo3.org/typo3cms/ExtbaseFluidBook/6-Persistence/5-modeling-the-class-hierarchy.html ], has a code example for "config.tx_extbase"; but it doesn't show the mapping lines themselves.
In my situation, I added TypoScript instructions in ext_typoscript_setup.txt to map the "header" and "bodytext" columns. I also deleted the recordType = Tx_Myextensionkey_Content line that Extension Builder wrote, because I want to read tt_content records that already exist, not records made by my extension.
config.tx_extbase{
persistence{
classes{
Mynamespace\Myextensionkey\Domain\Model\Content {
mapping {
tableName = tt_content
columns {
header.mapOnProperty = header
bodytext.mapOnProperty = bodytext
}
}
}
}
}
}
My TYPO3 extension can now read from tt_content.
Note: Giving a value to recordType in ext_typoscript_setup.txt causes the Extbase persistence layer to search for that one value in the underlying tt_content.CType column. Extbase does this through its \TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager getConfiguration() $frameworkConfiguration array, and its \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory buildDataMapInternal() function. As of this writing, you cannot use a wildcard character such as * or % in your recordType value; and you cannot give a value list such as text, textmedia.
I am using Typo3 V6.2.
I create a style table-1 for the my custom tables inserted with the RTE.
Everything is OK and I can select the table-1 style in the table properties panel.
But in front end Typo3 generates the following code : .
I guess I have somme TS to write to allow TYPo3 to use this class un FE, but what?
The following TypoScript setup configuration allows the frontend parser to keep your individual table css class yourCSSClass:
lib.parseFunc_RTE.externalBlocks.table.stdWrap.HTMLparser.tags.table.fixAttrib.class.list:= addToList(yourCSSClass)
Assuming i got a table called Countries and using Entity Framework, i want to know how could i populate the available countries (listed in the table countries) to view as drop down list and return the value to HTTPPost Controller
i got
public ActionResult SignUp()
i think the populate code should be here but i not sure
how to retrieve from entity framework and populate into view
and
[httpPost]
public ActionResult SignUp()
i want to read the user selected value and i think is
int value = form["DropDownListName"].SelectedIndex + 1;
can anyone please guide me on this with some hint or example , please ? Thx a lot =D
To be honest, you're not really working in an MVC pattern here. Don't put UI construction logic in your constructor.
Rather, expose the ID that you want to bind to the list via a model that you pass to a View() method in your constructor.
In your view, use the name of that property as the Name of a Drop-down and create a helper class to generate the list of values.
I'd give you a more specific example, but I'm in the cinema with my iPad, so a bit stuck for access to Visual Studio at the moment!