我们什么时候使用元素?我们什么时候使用助手?我们什么时候使用视图单元格?用cakephp3

我们什么时候使用元素?我们什么时候使用助手?我们什么时候使用视图单元格?用cakephp3,cakephp,cakephp-3.0,Cakephp,Cakephp 3.0,我使用的是CakePHP3.x 我正在尝试将themeforest主题封装到CakePHP插件中 中途,我正在决定是否将portlet皮肤化为助手、元素或视图单元 portlet html代码如下所示: <!-- BEGIN SAMPLE FORM PORTLET--> <div class="portlet box yellow"> <div class="po

我使用的是CakePHP3.x

我正在尝试将themeforest主题封装到CakePHP插件中

中途,我正在决定是否将portlet皮肤化为助手、元素或视图单元

portlet html代码如下所示:

                <!-- BEGIN SAMPLE FORM PORTLET-->
                <div class="portlet box yellow">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="fa fa-gift"></i> More Form Samples
                        </div>
                        <div class="tools">
                            <a href="" class="collapse">
                            </a>
                            <a href="#portlet-config" data-toggle="modal" class="config">
                            </a>
                            <a href="" class="reload">
                            </a>
                            <a href="" class="remove">
                            </a>
                        </div>
                    </div>
                    <div class="portlet-body">
                        <h4>Inline Form</h4>
                        <form class="form-inline" role="form">
                            <div class="form-group">
                                <label class="sr-only" for="exampleInputEmail2">Email address</label>
                                <input type="email" class="form-control" id="exampleInputEmail2" placeholder="Enter email">
                            </div>
                            <div class="form-group">
                                <label class="sr-only" for="exampleInputPassword2">Password</label>
                                <input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password">
                            </div>
                            <div class="checkbox">
                                <label>
                                <input type="checkbox"> Remember me </label>
                            </div>
                            <button type="submit" class="btn btn-default">Sign in</button>
                        </form>
                        <hr>
                        <h4>Inline Form With Icons</h4>
                        <form class="form-inline" role="form">
                            <div class="form-group">
                                <label class="sr-only" for="exampleInputEmail22">Email address</label>
                                <div class="input-icon">
                                    <i class="fa fa-envelope"></i>
                                    <input type="email" class="form-control" id="exampleInputEmail22" placeholder="Enter email">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="sr-only" for="exampleInputPassword42">Password</label>
                                <div class="input-icon">
                                    <i class="fa fa-user"></i>
                                    <input type="password" class="form-control" id="exampleInputPassword42" placeholder="Password">
                                </div>
                            </div>
                            <div class="checkbox">
                                <label>
                                <input type="checkbox"> Remember me </label>
                            </div>
                            <button type="submit" class="btn btn-default">Sign in</button>
                        </form>
                        <hr>
                        <h4>Horizontal Form</h4>
                        <form class="form-horizontal" role="form">
                            <div class="form-group">
                                <label for="inputEmail1" class="col-md-2 control-label">Email</label>
                                <div class="col-md-4">
                                    <input type="email" class="form-control" id="inputEmail1" placeholder="Email">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputPassword12" class="col-md-2 control-label">Password</label>
                                <div class="col-md-4">
                                    <input type="password" class="form-control" id="inputPassword12" placeholder="Password">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-offset-2 col-md-4">
                                    <div class="checkbox">
                                        <label>
                                        <input type="checkbox"> Remember me </label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-offset-2 col-md-10">
                                    <button type="submit" class="btn blue">Sign in</button>
                                </div>
                            </div>
                        </form>
                        <hr>
                        <h4>Horizontal Form With Icons</h4>
                        <form class="form-horizontal" role="form">
                            <div class="form-group">
                                <label for="inputEmail12" class="col-md-2 control-label">Email</label>
                                <div class="col-md-4">
                                    <div class="input-icon">
                                        <i class="fa fa-envelope"></i>
                                        <input type="email" class="form-control" id="inputEmail12" placeholder="Email">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputPassword1" class="col-md-2 control-label">Password</label>
                                <div class="col-md-4">
                                    <div class="input-icon right">
                                        <i class="fa fa-user"></i>
                                        <input type="password" class="form-control" id="inputPassword1" placeholder="Password">
                                    </div>
                                    <div class="help-block">
                                         with right aligned icon
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-offset-2 col-md-4">
                                    <div class="checkbox">
                                        <label>
                                        <input type="checkbox"> Remember me </label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-offset-2 col-md-10">
                                    <button type="submit" class="btn green">Sign in</button>
                                </div>
                            </div>
                        </form>
                        <hr>
                        <h4>Column Sizing</h4>
                        <form role="form">
                            <div class="row">
                                <div class="col-md-2">
                                    <input type="text" class="form-control" placeholder=".col-md-2">
                                </div>
                                <div class="col-md-3">
                                    <input type="text" class="form-control" placeholder=".col-md-3">
                                </div>
                                <div class="col-md-4">
                                    <input type="text" class="form-control" placeholder=".col-md-4">
                                </div>
                                <div class="col-md-3">
                                    <input type="text" class="form-control" placeholder=".col-md-2">
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <!-- END SAMPLE FORM PORTLET-->

更多表格样本
内联表单
电子邮件地址
密码
记得我吗
登录

带图标的内联表单 电子邮件地址 密码 记得我吗 登录
水平形式 电子邮件 密码 记得我吗 登录
带图标的水平窗体 电子邮件 密码 带右对齐图标 记得我吗 登录
柱尺寸
外观如下:

我的问题是,我们如何知道何时应该使用元素?我们什么时候应该使用助手?我们什么时候应该使用视图单元格


我应该使用哪种情况来进行上述操作?我倾向于帮助者。

元素

当您需要大量重复与演示文稿相关的内容(通常是HTML)时,可以使用它。例如,我有一个项目,其中三个表使用地址表的记录。这三个元素中包含地址数据的组成部分是一个元素

助手


使用它来封装视图logik,如果可能的话,不要把HTML或者其他与表示相关的东西放进去。例如,让它做一些事情,根据结果,您可以使用该结果类型的元素来呈现数据:
return$this->\u view->render('items/'.$type.\u item')

如果查看核心帮助程序,例如HtmlHelper,您将看到一个属性:

protected$\u defaultConfig=[
protected $_defaultConfig = [
    'templates' => [
    'meta' => '<meta{{attrs}}/>',
    'metalink' => '<link href="{{url}}"{{attrs}}/>',
    /*...*/