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.

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度