7.4.1.3 meta
meta(string $type, string $url = null, array $attributes = array())
This method is handy for linking to external resources like RSS/Atom feeds and favicons. Like css(), you can specify whether or not you'd like this tag to appear inline or in the head tag by setting the 'inline' key in the $attributes parameter to false, ie - array('inline' => false).
If you set the "type" attribute using the $attributes parameter, CakePHP contains a few shortcuts:
| type | translated value |
|---|---|
| html | text/html |
| rss | application/rss+xml |
| atom | application/atom+xml |
| icon | image/x-icon |
<?php echo $this->Html->meta(
'favicon.ico',
'/favicon.ico',
array('type' => 'icon')
);?> //Output (line breaks added) </p>
<link
href="http://example.com/favicon.ico"
title="favicon.ico" type="image/x-icon"
rel="alternate"
/>
<?php echo $this->Html->meta(
'Comments',
'/comments/index.rss',
array('type' => 'rss'));
?>
//Output (line breaks added)
<link
href="http://example.com/comments/index.rss"
title="Comments"
type="application/rss+xml"
rel="alternate"
/>
<?php echo $this->Html->meta('favicon.ico','/favicon.ico',array('type' => 'icon'));?> //Output (line breaks added) </p><linkhref="http://example.com/favicon.ico"title="favicon.ico" type="image/x-icon"rel="alternate"/><?php echo $this->Html->meta('Comments','/comments/index.rss',array('type' => 'rss'));?>//Output (line breaks added)<linkhref="http://example.com/comments/index.rss"title="Comments"type="application/rss+xml"rel="alternate"/>
This method can also be used to add the meta keywords and descriptions. Example:
<?php echo $this->Html->meta(
'keywords',
'enter any meta keyword here'
);?>
//Output <meta name="keywords" content="enter any meta keyword here"/>
//
<?php echo $this->Html->meta(
'description',
'enter any meta description here'
);?>
//Output <meta name="description" content="enter any meta description here"/>
<?php echo $this->Html->meta('keywords','enter any meta keyword here');?>//Output <meta name="keywords" content="enter any meta keyword here"/>//<?php echo $this->Html->meta('description','enter any meta description here');?>//Output <meta name="description" content="enter any meta description here"/>
If you want to add a custom meta tag then the first parameter should be set to an array. To output a robots noindex tag use the following code:
echo $this->Html->meta(array('name' => 'robots', 'content' => 'noindex')); echo $this->Html->meta(array('name' => 'robots', 'content' => 'noindex'));


























