After installing CakePHP successfully, on first time running, I'm getting these warnings at the bottom. How can I fix this.
Warning (2): Missing argument 1 for View::element(), called in /Users/michaelanywar/Sites/cakephp/app/View/Layouts/default.ctp on line 61 and defined [CORE/Cake/View/View.php, line 398]
Notice (8): Undefined variable: name [CORE/Cake/View/View.php, line 416]
Notice (8): Undefined variable: name [CORE/Cake/View/View.php, line 422]
Notice (1024): Element Not Found: Elements/.ctp [CORE/Cake/View/View.php, line 425]
My View/view.php lines from 398 to 427 look like this:
public function element($name, $data = array(), $options = array()) {
$file = $plugin = null;
if (isset($options['plugin'])) {
$name = Inflector::camelize($options['plugin']) . '.' . $name;
}
if (!isset($options['callbacks'])) {
$options['callbacks'] = false;
}
if (isset($options['cache'])) {
$contents = $this->_elementCache($name, $data, $options);
if ($contents !== false) {
return $contents;
}
}
$file = $this->_getElementFilename($name);
if ($file) {
return $this->_renderElement($file, $data, $options);
}
if (empty($options['ignoreMissing'])) {
list ($plugin, $name) = pluginSplit($name, true);
$name = str_replace('/', DS, $name);
$file = $plugin . 'Elements' . DS . $name . $this->ext;
trigger_error(__d('cake_dev', 'Element Not Found: %s', $file), E_USER_NOTICE);
}
}
If you look at your first warning/error message it should be clear what the issue is: "Warning (2): Missing argument 1 for View::element()".
Look on line 61 of your default layout View template (/app/View/Layouts/default.ctp). You obviously have a call to $this->element()
that isn't passing a template name (hence Cake is looking for "Elements/.ctp").
Make sure you pass a template name to the element()
method or remove it from your template. For example, if you want to include the template "View/Elements/site_header.ctp":-
echo $this->element('site_header');
The template just needs to exist in the 'View/Elements' folder. You don't need to pass the '.ctp' extension to the element()
method, Cake assumes this.
Make sure you've read the docs on Elements.