call to undefined function View::fetch cakePHP - php

I started experimenting with CakePHP version 2.x, I created a default.ctp layout file in View/Layouts inside of which I have codes like:
echo $this->fetch('css');
but I keep getting the following error:
Fatal error: Call to undefined method View::fetch() in C:\wamp\www\.......
I tried creating a block for this css in my view file like:
$this->start('css');
$this->Html->css('home_page', null, array('inline' => false));
$this->end();
But when I do this I get the following error:
Fatal error: Call to undefined method View::start() in C:\wamp\www\.......
Any help please?!!!
Thank you

View::fetch() is available since 2.1, what is your version?

I dont think you need fetch, start, end for including css, you can just use:
$this->Html->css(array('home_page.css'));
//OR
echo $this->fetch('css'); //from version 2.1
Ref: Css CakePHP

The book is a little ahead of the release atm! fetch() is from 2.1 code, which is still alpha.
Try generating a default layout using cake's bake tool and study that to see how 2.0 does it, and make sure do you don't follow bits of the book which say they are new in 2.1 until you are using the 2.1 codebase.

Related

Fatal error: Call to undefined method Google_IO_Curl::authenticatedRequest()

When using the described in the Google Contacts API example simple.php, and the Google API PHP Client from GitHub, version 1.0.4-beta, I get the following error:
Fatal error: Call to undefined method Google_IO_Curl::authenticatedRequest()
However, when I change this line...
$val = $client_svc_contacts->getIo()->authenticatedRequest($req);
...to...
$val = $client_svc_contacts->getAuth()->authenticatedRequest($req);
...then it starts working again.
I am using version 1.0.4-beta unmodified except for the addition of the following line at the top of Client.php:
set_include_path(str_replace('/Google','',dirname(__FILE__)));
I recognize that simple.php was written for version 0.6, not v1+, but is the example just out of date compared to the version on GitHub? Or is there something wrong with my implementation?
Found a migration guide that had the answer ...
A new home for authenticatedRequest
The authenticatedRequest method has been moved from the io classes to
the auth classes.
So it appears that replacing getIo() with getAuth() was the correct course of action.

CakePHP: Fatal error: Call to a member function image()

I'm using the following Helper: http://pastebin.com/qBs2GvG4 in my CakePHP 2.0 app to show a gravatar for a user like so:
<?php $this->Gravatar->image($profile['User']['email'], array('default'=>'mm','size'=>48)); ?>
However it gives the error:
Fatal error: Call to a member function image() on a non-object in /Users/cameron/Sites/social/app/View/Helper/GravatarHelper.php on line 97
Any ideas what the problem is? This worked in my 1.3 app so wondering if something has changed between 1.3 and 2.0 that causes this issue? Thanks
Helpers have slightly different dependencies in 2.0, especially if they require other helpers.I actually made the commits to fix this one in the CakeDC utils plugin.
You can find an updated version of that helper here: https://github.com/CakeDC/utils/blob/2.0/View/Helper/GravatarHelper.php
Looks like the GravatarHelper has a dependency on the HtmlHelper. Is Html in your list of helpers in the controller?

kohana 3.0.12 how to log

i am working on an website on kohana 3.0.12 and i have installed a module that loggs me some errors. All works fine, except that, when i want to effectively log an error, i get an error and i don;t know how to manage it.
Here is the messy code:
public static function handler(Exception $e)
{
// It's a nice time to log :)
Kohana::$log->add(Kohana::ERROR, Kohana_Exception::text($e));
etc code here
well that Kohana_Exception::text($e) causes an exception like: Call to undefined method Kohana_Exception::text() ? i guess it is a framework bug. any idea of how i can solve the problem? (i guess i should use another instance but Kohana_Exception:: but what instance?)
thank you
You get this error because neither Kohana_Exception nor Exception classes don't have text() method. I think the author of the module wanted to write like this:
Kohana::$log->add(Kohana::ERROR, Kohana::exception_text($e));
I belive the exception handling in 3.0 is located in the Kohana class. Try Kohana::exception(), or look in api guide if that isn't it.

Third-party library not loading in Expression Engine 2.0

I'm developing a properties module for Expression Engine that's to take properties from Rightmove's BLM format and populate a database, and then those properties be searchable from the front-end.
I've found a CodeIgniter library (http://biostall.com/codeigniter-rightmove-blm-parser-library) that does the heavy lifting of the BLM files. However, I can't seem to load it.
My code in mcp.properties.php looks like this:
$config = array();
$this->EE->load->library('rightmove_v3_parser');
$this->rightmove_v3_parser->initialize($config);
$data['properties'] = $this->rightmove_v3_parser->process();
print '<pre>'; print_r($data['properties']); print '</pre>';
exit;
The library files are in a libraries sub-folder in my properties add-on folder under /system/expressionengine/third_party/.
However, when using the above code, I get the following error in Expression Engine:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Properties_mcp::$Rightmove_v3_parser
Filename: properties/mcp.properties.php
Line Number: 44
Fatal error: Call to a member function initialize() on a non-object in /Users/Martin/Sites/expressionengine/system/expressionengine/third_party/properties/mcp.properties.php on line 4
Where am I going wrong? Why can't I bundle this library with my add-on and call it within my add-on?
You've missed the EE object when referencing the library. So after loading the library you should use
$this->EE->rightmove_v3_parser
to access it, rather than
$this->rightmove_v3_parser
Have you included the library at the top of your plugin, i could be wrong but I don't think loading a library like that will work from a library subdir in your third_party plugin folder. Try including the library at the top of your plugin.

Trying to install Auth for CI: Call to undefined method CI_Loader::setdata()

I have been trying to implement an auth system for Codeigniter. I wanted to save time, though it hasn't succeeded so far.
The system I'm trying to implement is: http://codeigniter.com/wiki/auth/
Currently I have some forms working, but the registration form generates a fatal error:
PHP Fatal error: Call to undefined method CI_Loader::setdata() in /Applications/MAMP/htdocs/CI+Login/system/application/controllers/auth.php on line 159
Anyone has an idea what that is about? Anyone has got this system running?
thx.
EDIT:
The code that generates the error is:
if ($this->config->item('auth_use_security_code'))
$this->authlib->register_init();
$data['countries'] = $this->Usermodel->getCountries();
$this->load->setdata($data);
The problem is that load does not contain a method named setdata, has it in a previous version of CI or what can I make of this?
Try this:
$this->load->vars($data);
or remove this line and use the second parameter of the $this->load->view() function.
$this->load->view($this->config->item('auth_register_view'),$data);

Categories