registerLinkTag() public method

For example, a link tag for a custom favicon can be added like the following: php $view->registerLinkTag(['rel' => 'icon', 'type' => 'image/png', 'href' => '/myicon.png']); which will result in the following HTML: . **Note:** To register link tags for CSS stylesheets, use View::registerCssFile instead, which has more options for this kind of link tag.
public registerLinkTag ( array $options, string $key = null )
$options array the HTML attributes for the link tag.
$key string the key that identifies the link tag. If two link tags are registered with the same key, the latter will overwrite the former. If this is null, the new link tag will be appended to the existing ones.
Example #1
0
 /**
  * (non-PHPdoc)
  * @see \yii\web\View::registerLinkTag()
  */
 public function registerLinkTag($options, $key = null)
 {
     if (ArrayHelper::keyExists('href', $options)) {
         $options['href'] = \Yii::getAlias($options['href']);
     }
     parent::registerLinkTag($options, $key);
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function registerLinkTag($options, $key = null)
 {
     $this->viewElementsGathener->gather(__FUNCTION__, func_get_args());
     return parent::registerLinkTag($options, $key);
 }