Hi,
ich habe die Extension pw_comments mit meiner Extension (my_pwcomments) um das Feld Subject erweitert.
Erstellt habe ich meine Extension mit dem Extensionbuilder. Das hat auch wunderbar geklappt und auslesen kann ich mein neues Feld "subject" im Template ganz einfach über {comment.subject}
Mein Typo3 ist das aktuelle 6.2.9
Hier das Mapping in ext_typoscript_setup.txt
config.tx_extbase{
persistence{
classes{
Tx_PwComments_Domain_Model_Comment {
subclasses {
Tx_MyPwcomment_Comment = MyTYPO3\MyPwcomment\Domain\Model\Comment
}
}
MyTYPO3\MyPwcomment\Domain\Model\Comment {
mapping {
tableName = tx_pwcomments_domain_model_comment
recordType = Tx_MyPwcomment_Comment
}
}
}
}
}
ext_tables.php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'my pwcomments');
\TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('tx_pwcomments_domain_model_comment');
if (!isset($GLOBALS['TCA']['tx_pwcomments_domain_model_comment']['ctrl']['type'])) {
if (file_exists($GLOBALS['TCA']['tx_pwcomments_domain_model_comment']['ctrl']['dynamicConfigFile'])) {
require_once($GLOBALS['TCA']['tx_pwcomments_domain_model_comment']['ctrl']['dynamicConfigFile']);
}
// no type field defined, so we define it here. This will only happen the first time the extension is installed!!
$GLOBALS['TCA']['tx_pwcomments_domain_model_comment']['ctrl']['type'] = 'tx_extbase_type';
$tempColumns = array();
$tempColumns[$GLOBALS['TCA']['tx_pwcomments_domain_model_comment']['ctrl']['type']] = array(
'exclude' => 1,
'label' => 'LLL:EXT:my_pwcomment/Resources/Private/Language/locallang_db.xml:tx_mypwcomment.tx_extbase_type',
'config' => array(
'type' => 'select',
'items' => array(),
'size' => 1,
'maxitems' => 1,
)
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tx_pwcomments_domain_model_comment', $tempColumns, 1);
}
$tmp_my_pwcomment_columns = array(
'subject' => array(
'exclude' => 1,
'label' => 'LLL:EXT:my_pwcomment/Resources/Private/Language/locallang_db.xml:tx_mypwcomment_domain_model_comment.subject',
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim'
),
),
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tx_pwcomments_domain_model_comment',
$tmp_my_pwcomment_columns
);
$GLOBALS['TCA']['tx_pwcomments_domain_model_comment']['types']['Tx_MyPwcomment_Comment']['showitem'] = $TCA['tx_pwcomments_domain_model_comment']['types']['1']['showitem'];
$GLOBALS['TCA']['tx_pwcomments_domain_model_comment']['types']['Tx_MyPwcomment_Comment']['showitem'] .= ',--div--;LLL:EXT:my_pwcomment/Resources/Private/Language/locallang_db.xml:tx_mypwcomment_domain_model_comment,';
$GLOBALS['TCA']['tx_pwcomments_domain_model_comment']['types']['Tx_MyPwcomment_Comment']['showitem'] .= 'subject';
$GLOBALS['TCA']['tx_pwcomments_domain_model_comment']['columns'][$TCA['tx_pwcomments_domain_model_comment']['ctrl']['type']]['config']['items'][] = array('LLL:EXT:my_pwcomment/Resources/Private/Language/locallang_db.xml:tx_pwcomments_domain_model_comment.tx_extbase_type.Tx_MyPwcomment_Comment','Tx_MyPwcomment_Comment');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'tx_pwcomments_domain_model_comment',
$GLOBALS['TCA']['tx_pwcomments_domain_model_comment']['ctrl']['type'],
'',
'after:' . $TCA['tx_pwcomments_domain_model_comment']['ctrl']['label']
);
Das Model:
namespace MyTYPO3\MyPwcomment\Domain\Model;
/**
* Comment
*/
class Comment extends \Tx_PwComments_Domain_Model_Comment {
/**
* subject
*
* @var string
*/
protected $subject = '';
/**
* Returns the subject
*
* @return string $subject
*/
public function getSubject() {
return $this->subject;
}
/**
* Sets the subject
*
* @param string $subject
* @return void
*/
public function setSubject($subject) {
$this->subject = $subject;
}
}
ich habe dann in constants und setup noch definiert das die templates aus meiner extension gelesen werden sollen
plugin.tx_pwcomments {
view {
templateRootPath = {$plugin.tx_pwcomments.view.templateRootPath}
partialRootPath = {$plugin.tx_pwcomments.view.partialRootPath}
layoutRootPath = {$plugin.tx_pwcomments.view.layoutRootPath}
}
settings {
sendMailTemplate = {$plugin.tx_pwcomments.settings.sendMailTemplate}
sendMailToAuthorAfterSubmitTemplate = {$plugin.tx_pwcomments.settings.sendMailToAuthorAfterSubmitTemplate}
sendMailToAuthorAfterPublishTemplate = {$plugin.tx_pwcomments.settings.sendMailToAuthorAfterPublishTemplate}
badWordsList = {$plugin.tx_pwcomments.settings.badWordsList}
}
}
Ein Problem bekomme ich aber leider beim Speichern:
#1297759968: Exception while property mapping at property path ""😛roperty "subject" was not found in target object of type "Tx_PwComments_Domain_Model_Comment".
Kann mir einer sagen wie das lösen kann, am besten ohne einen eigenen Controller zu schreiben zu müssen 😉
Grüße boOgiE