Hi,
I am a newbie at Yii. I am trying to create a widget which gets the RSS feed.
It is working fine, but I want to know am I doing it the right way?
/protected/components/TestWidget.php
And in main.php I am simply doing.
But on the wiki pages and on forum I have seen rendering it to the view /protected/components/views/testWidget.php file.
Thanks.
I am a newbie at Yii. I am trying to create a widget which gets the RSS feed.
It is working fine, but I want to know am I doing it the right way?
/protected/components/TestWidget.php
class TestWidget extends CWidget
{
public function run()
{
$feed_url = '---url---';
$feed = simplexml_load_file($feed_url);
foreach($feed -> entry as $item)
{
$title = $item -> title;
$url = $item -> id;
echo '<strong>Title is: </strong>' . $title . '<br />';
echo '<strong>Url is: </strong>' . $url . '<br />';
}
}
}
And in main.php I am simply doing.
<div ...... >
<h4>My Widget</h4>
<?php
$this->widget('application.components.TestWidget');
?>
</div>
But on the wiki pages and on forum I have seen rendering it to the view /protected/components/views/testWidget.php file.
Thanks.