0
TYPO3 8.7.4 新闻6.0.0
是否有可能在news_extend延伸与第二容器延伸新闻延伸? (如contentElements) 目标是将第二个容器放置在详细信息页面的相关内容中。
有没有例子?
TYPO3 8.7.4 新闻6.0.0
是否有可能在news_extend延伸与第二容器延伸新闻延伸? (如contentElements) 目标是将第二个容器放置在详细信息页面的相关内容中。
有没有例子?
这应该工作。只需按照文档
中所述的方式扩展新闻tca和模型,是的,这很容易。您需要将字段添加到数据库,在TCA中进行配置,扩展新闻模型并调整详细信息模板。
CREATE TABLE tx_news_domain_model_news ( tx_newsextend_content_elements_second text );
$newNewsColumns = [ 'tx_newsextend_content_elements_second' => [ // .... here copy the original 'content_elements' field's config from ext news' TCA. update the label to yours. ]; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tx_news_domain_model_news', $newNewsColumns); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tx_news_domain_model_news', 'tx_newsextend_content_elements_second', '', 'after:content_elements');
... <trans-unit id="tx_news_domain_model_news.tx_newsextend_content_elements_second"> <source>Additional content elements</source> </trans-unit>
namespace [my vendor]\NewsExtend\Domain\Model; class News extends \GeorgRinger\News\Domain\Model\News { // here copy all uses of contentElement field from original model, only name it txNewsextendContentElementsSecond. // watch whether it's only declared property and getter/setter (simple fields), or something more is done in the model and do it the same way as there. // tip: see getContentElementIdList() method }
$GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['classes']['Domain/Model/News'][] = 'news_extend';
<f:if condition="{newsItem.txNewsExtendContentElementsSecond}"> <!-- content elements second --> <f:cObject typoscriptObjectPath="lib.tx_news.contentElementRendering">{newsItem.txNewsExtendContentElementsSecondIdList}</f:cObject> </f:if>
,如果你复制粘贴,我从我的笔记写在它上面可能不只是工作。但它会帮助你明白这个想法。祝你好运
非常感谢。 我认为有一个表丢失(也在新的tca中发生变化): tx_news_related_news_2模拟到tx_news_related_news。没有这个表我不会分开两个容器。 –