CakePHP 1.3 Html助手 - 未定义属性错误

时间:2014-03-04 16:30:49

标签: jquery cakephp undefined cakephp-1.3 helpers

我正在使用cakePHP 1.3并且遇到了html-helper的问题。

我想使用自动完成功能,因此我需要在我的视图中加载html-helper(例如加载css)。首先,我遵循了本教程:JQuery autocomplete in CakePHP

但是javascript与现在的html存在同样的问题。然后我尝试了教程的新版本:CakePHP and jQuery auto-complete revisited

我知道新教程是为CakePHP 2.3编写的,但我读到了对于CakePHP 1.3,jQuery的功能应该是相同的。

所以我的观点的标题如下:

<?php
  echo $this->Html->css('https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css'); ?>

但是这会引发以下错误:

  

注意(8):未定义的属性:View :: $ Html   [APP \ views \ produkt \ show.ctp,第5行]致命错误:致电会员   函数css()在非对象

在任何情况下(css,jquery,...)都会发生此错误。所以在我看来问题属于帮手。如果我使用脚本方法。

html-helper存在于我的cake / libs / views / helpers文件夹中。我也将它加载到produkt_controller中:

class ProduktController extends AppController {
var $helpers = array (
        'Html',
        'Check',
        'Misc'
);

我已经在这里寻找解决方案,但没有找到适合我的答案。可悲的是,这篇文章how to include javascript in cakephp 1.3?中提到的cakePHP的链接在某种程度上被打破了,我没有在cakePHP 1.3的cookbook中找到我的问题的答案。

如果有人可以帮我帮助帮助我,那就太棒了!

1 个答案:

答案 0 :(得分:1)

在1.3中它是

$html->methodName()

而在2.0中它变成了

$this->Html->methodName()

为什么要阅读2.0的文档? The documentation for 1.3 is still up