Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0 Htmlhelper::meta() doesn't allow custom metatags to be added #3553

Closed
ghost opened this issue May 23, 2014 · 4 comments
Closed

3.0 Htmlhelper::meta() doesn't allow custom metatags to be added #3553

ghost opened this issue May 23, 2014 · 4 comments
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented May 23, 2014

v3.0 documentation states: "If you want to add a custom meta tag then the first parameter should be set to an array." However, if you set to an array it fails.

Code in view/layout:

echo $this->Html->meta(['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1']);

Error

Warning (2): Illegal offset type in isset or empty [ROOT\vendor\cakephp\cakephp\src\View\Helper\HtmlHelper.php, line 223]

I was able to get the right output by added a check in the method like this (line 223)

if (is_array($type)) {
    // skip
} elseif (isset($types[$type])) {

Can the HTML Helper be fixed, or the documentation updated.

@markstory markstory added this to the 3.0.0 milestone May 23, 2014
@markstory markstory self-assigned this May 23, 2014
@markstory
Copy link
Member

The documentation is incorrect. In the migration guide

HtmlHelper::meta() now requires $type to be a string. Additional options can further on be passed as $options.

With that said, there isn't a simple way to make a viewport meta tag. I'll add a better way to make viewport tags, as they are pretty common.

@ADmad
Copy link
Member

ADmad commented May 23, 2014

Or one can directly write them in HTML :)

@markstory
Copy link
Member

The documentation has been updated to not lie in cakephp/docs@56f2abb

@markstory
Copy link
Member

Closing as a viewport type has been added and the documentation has been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants