我想为我的应用程序设置一个徽标。如何在cakephp的“configure :: write()”中添加图片链接?
在我AppController.php
页我写了下面的代码行:
Configure::write('CompanyLogo','echo $this->Html->image('logo.png', $options = array());');"
但是,这不是为我工作。你有什么建议如何使它工作?谢谢
我想为我的应用程序设置一个徽标。如何在cakephp的“configure :: write()”中添加图片链接?
在我AppController.php
页我写了下面的代码行:
Configure::write('CompanyLogo','echo $this->Html->image('logo.png', $options = array());');"
但是,这不是为我工作。你有什么建议如何使它工作?谢谢
不要在函数参数中使用“回声”。所以它应该是 Configure :: write('CompanyLogo',$ this-> Html-> image('logo.png'));
这将产生错误,如“调用成员函数的图像()在AppController中的非对象” – 2015-04-01 05:27:10
控制器和助手在视图中的组件。您目前正在尝试在控制器中使用助手,这将无法工作。 而不是写在配置的IMAGE_NAME:
`Configure::write('Config.logo', 'logo.png');`
使用到这个布局/视图
$image_name= Configure::read('logo');
$this->Html->image($image_name, array());
你可以简单地写在“配置::写”映像路径和访问它在照片喜欢: 配置:: write('CompanyLogo',$ this-> webroot。“img/logo.png”); 并鉴于你可以使用这个: < IMG SRC = “?< PHP的echo配置::读( 'CompanyLogo的');?>”/>
但是使用这个考虑到良好的做法: $ this-> Html-> image('logo.png');
你有没有得到任何错误?帮助我们来帮助你 – Ethaan 2015-04-01 04:28:30