博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用widget控件的一般规律!!!
阅读量:4200 次
发布时间:2019-05-26

本文共 1200 字,大约阅读时间需要 4 分钟。

widget控件:

 

1

在使用widget控件的block,一般是不指定template的。

要么通过$this->$this->setTemplate('widget/form/container.phtml'),自己指定,

要么通过父类的构造函数里面的执行语句: $this->setTemplate('widget/form/container.phtml');来指定

2

加载子block:

$this->setChild('form', $this->getLayout()->createBlock($this->_blockGroup . '/' . $this->_controller . '_' . $this->_mode . '_form'));

一般是通过上面的方法加载,在子类中定义变量,在父类中通过上面的方法生成!

3

显示内部控件。

3.1直接通过调用子block显示内部控件的,getChildHtml。

3.2先调用一个函数,譬如:getFormHtml,通过函数读取action,然后得到内部控件显示的信息,然后再使用getChildHml()显示出来!

譬如: 

 

 public function getFormHtml()

    {   //$this->_children[$name];

        $this->getChild('form')->setData('action', $this->getSaveUrl());

        return $this->getChildHtml('form');

    }

 

 

 

  public function     gettSaveUrl()

    {

        return $this->getFormActionUrl();

    }

 

 

 

  public function getFormActionUrl()

    {

        if ($this->hasFormActionUrl()) {

            return $this->getData('form_action_url');

        }

        return $this->getUrl('*/' . $this->_controller . '/save');

    }

 

将得到的action赋值于form,然后再执行getChildHtml()方法,加载子block。

 

4指定phtml,子block如果有孙block的话,继续通过setChild方法加载。

 

5以上为空间包含加载的方式。

在加载前,也就是block里面的php文件,执行__construction(),_prepareLayout()方法,提供1.css标示信息(如id,destElementId等),2路径信息,3加载的子block,4按钮信息等。为子block的执行提供使用的信息。

 

6当然,在执行前,model,helper,controllers,etc,sql,都要配置好!!

 

 

 

转载地址:http://grdli.baihongyu.com/

你可能感兴趣的文章
交大我来了--周末再见了
查看>>
网页中flash wmode属性
查看>>
挑战自我,勇攀高峰
查看>>
神奇的HTML5画图应用
查看>>
flex 滚动条问题
查看>>
软件开发管理中的博奕论
查看>>
计算机认证考试种类
查看>>
SQL in和exists 比较
查看>>
社会性网络服务(SNS)研究
查看>>
鼠标DarkField技术
查看>>
傻傻的我
查看>>
paypal 沙盒账号注册
查看>>
ebay 沙盒账号注册
查看>>
linux -8 Linux磁盘与文件系统的管理
查看>>
linux -8 Linux磁盘与文件系统的管理
查看>>
linux 9 -文件系统的压缩与打包 -dump
查看>>
PHP在变量前面加&是什么意思?
查看>>
ebay api - GetUserDisputes 函数
查看>>
ebay api GetMyMessages 函数
查看>>
wdlinux
查看>>