dtpngq3378499 2016-09-15 08:23
浏览 23
已采纳

哪个是使用extbase创建页面的最佳方法?

i have seen that are two ways to create new pages with extbase, once with datamap like this:

$data = array(
 ‚pages‘ => array(
 ‚NEW_1‘ => array(
   ‚pid‘ => 1,
   ‚title‘ => ‚Hello World‚
 ),
)
); 

$tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
$tce->start($data, array());
$tce->process_datamap();
\TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
$tce->clear_cacheCmd('pages');

And the other way with mapping like this

Model

class Pages extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity{
…
}

Repository

   class PagesRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
 …
}

Controller

$page->setTitle('Hell World');
$this->pagesRepository->add($page);

TypoScript

persistence{
        classes{
        <Vendor>\<extKey>\Domain\Model\Pages{
          mapping{
           tableName = pages
           columns{
            title.mapOnProperty = title
            …
           }
          }     
        }
       }
}

Which one should I use to create pages and what is the difference between both of them?

  • 写回答

1条回答 默认 最新

  • duanlaiquan8174 2016-09-15 09:33
    关注

    I would go the the approach using the DataMapper as it takes better care about the interals of TYPO3 like the refindex.

    If I would need to create a custom model with relations, I would use extbase as it is just less work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示