yii\web\View::registerMetaTag PHP Метод

registerMetaTag() публичный Метод

For example, a description meta tag can be added like the following: php $view->registerMetaTag([ 'name' => 'description', 'content' => 'This website is about funny raccoons.' ]); will result in the meta tag .
public registerMetaTag ( array $options, string $key = null )
$options array the HTML attributes for the meta tag.
$key string the key that identifies the meta tag. If two meta tags are registered with the same key, the latter will overwrite the former. If this is null, the new meta tag will be appended to the existing ones.
    public function registerMetaTag($options, $key = null)
    {
        if ($key === null) {
            $this->metaTags[] = Html::tag('meta', '', $options);
        } else {
            $this->metaTags[$key] = Html::tag('meta', '', $options);
        }
    }

Usage Example

Пример #1
1
 /**
  * @param View $view
  */
 public function applyTo(View $view)
 {
     $attributes = $this->getAttributes(null, ['id', 'meta_id']);
     foreach ($attributes as $name => $value) {
         $view->registerMetaTag(['property' => 'twitter:' . $name, 'content' => $value]);
     }
 }
All Usage Examples Of yii\web\View::registerMetaTag