根据OctoberCMS文档的这一部分,我应该可以设置这样的目录结构:
pluginname
??? components
? ??? resumefilter
? ? ??? default.htm
? ? ??? my-partial.htm
? ??? ResumeFilter.php
? ??? resumelist
? ? ??? default.htm
? ??? ResumeList.php
Run Code Online (Sandbox Code Playgroud)
然后,我应该能够ResumeFilter.php像这样放一个函数:
function onFilterResumes()
{
return ['#someDiv' => $this->renderPartial('my-partial.htm')];
}
Run Code Online (Sandbox Code Playgroud)
最后,default.htm标记中的一个按钮:
<button
class="btn btn-success"
data-request="onFilterResumes">
Filter
</button>
Run Code Online (Sandbox Code Playgroud)
问题是,当我按下按钮时,它说 The partial 'my-partial.htm' is not found
我已经尝试了完整的路径,但它似乎没有任何区别.
十月似乎在寻找部分主题partials目录,因为如果我把它放在那里它会加载.但是,在名称前加上resumefilter:试图让它在组件中查找是行不通的,并且文档似乎建议它应该在没有前缀的组件中查找.
@如果要渲染组件部分,请在部分名称前添加.所以你的代码应该是这样的,
function onFilterResumes()
{
return ['#someDiv' => $this->renderPartial('@my-partial.htm')];
}
Run Code Online (Sandbox Code Playgroud)
如果要覆盖主题中的partial,请将partial放在以下树中,
themes/theme-name/partials/component-name/my-partial.htm
| 归档时间: |
|
| 查看次数: |
3179 次 |
| 最近记录: |