Page header.

Let's say I have a layout view for several views, which are inside [tt]<body></body>[/tt]. One of these views renders a list of news reports, and I liked to incorporate a RSS feed to that page, in this way:

<head>


...


<link rel="alternate" type="application/rss+xml" title="CNN - Top Stories [RSS]" href="http://rss.cnn.com/rss/edition.rss">


...


</head>

where the href is not static.

Can I do this with Yii?

Also, I have a javascript file which needs to be included in the pages' header. Is this possible?

Thanks.

Note: in prado it was possible using THead.

For javascript, you can use the following:



$this->clientScript->registerScriptFile($url);


For RSS href, you would need to define a property in your controller base class that returns the needed URL. Then in the layout, simply do <?php echo $this->rssUrl; ?>

Quote

For javascript, you can use the following:


$this->clientScript->registerScriptFile($url);


Thanks, haven’t seen that, sorry :-[

Quote

For RSS href, you would need to define a property in your controller base class that returns the needed URL. Then in the layout, simply do <?php echo $this->rssUrl; ?>

Ok, tried and worked just fine :slight_smile:

<html>


<head>


<?php


if (isset($this->rssURLs) && is_array($this->rssURLs) && !empty($this->rssURLs)) {


   foreach ($this->rssURLs as $url) {


      echo '<link rel="alternate" type="application/rss+xml" title="'.$url['name'].'" href="'.$url['url'].'" />' . "n";


   }


}


?></head>


...

where [tt]rssURLs[/tt] is a public property of the page's controller.