dox19458 2017-05-18 12:34
浏览 42

如何更改OctoberCMS组件中呈现的部分?

By default, OctoberCMS plugin components render the partial default.htm. Is it possible to override which partial will be rendered? For example ...

Plugin file structure

├── components
│   ├── example
│   │   ├── default.htm
│   │   ├── other_partial.htm
│   ├── Example.php
├── ...
├── Plugin.php

Example.php

class Example extends ComponentBase  {

   public function onRun() {
       // change the rendered partial, such that other_partial.htm
       // will be rendered instead of default.htm
       $this->setRenderedPartial('other_partial')
   }

}

I know that it is possible to render the other_partial from inside the default.htm but in my case I seek to leave the default.htm untouched and render the other partial as default instead.

  • 写回答

5条回答 默认 最新

  • douweibeng5219 2017-05-18 18:15
    关注

    The way I would do this in October is to handle this on the page template with some logic in Twig. This would probably be the most logic place to put it in my opinion.

    评论

报告相同问题?

悬赏问题

  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了