摘要:TEEBB使用了SonataBlockBundle,内置了一些展示列表的block_type。我们使用如下代码可获取“文章”类型的内容列表: {{ sonata_block_render({type:'teebb.core.block.conte...
TEEBB使用了SonataBlockBundle,内置了一些展示列表的block_type。我们使用如下代码可获取“文章”类型的内容列表:
{{ sonata_block_render({type:'teebb.core.block.contents'}, {
limit: 5,
order: {createdAt: 'DESC'},
criteria: {typeAlias: 'article'}
}) }}
使用Symfony命令行查看完整参数配置:
symfony console debug:sonata:block
#block的type及设置列表
>> teebb.core.block.contents
#要搜索的EntityType的Entity,默认搜索内容,也可搜索分类、用户等其他EntityType的Entity
entity_class "Teebb\\CoreBundle\\Entity\\Content"
label "" #块标题
translation_domain "messages" #translation_domain
limit 5 #数量限制
#默认的block模板
template "@TeebbCore\/blocks\/last_contents.html.twig"
criteria [] #过滤条件
order [] #结果排序
exclude [] #排除条件