7.4.1.3 meta
meta(string $type, string $url = null, array $attributes = array(), boolean $inline = true)
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 using the fourth parameter.
If you set the "type" attribute using the $htmlAttributes 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 $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 $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 $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 $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 $html->meta(
'keywords',
'enter any meta keyword here'
);?>
//Output <meta name="keywords" content="enter any meta keyword here"/>
//
<?php echo $html->meta(
'description',
'enter any meta description here'
);?>
//Output <meta name="description" content="enter any meta description here"/>
<?php echo $html->meta('keywords','enter any meta keyword here');?>//Output <meta name="keywords" content="enter any meta keyword here"/>//<?php echo $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 $html->meta(array('name' => 'robots', 'content' => 'noindex')); echo $html->meta(array('name' => 'robots', 'content' => 'noindex'));
