Yii Framework Forum: How to add "Links" widget to the blog demo - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to add "Links" widget to the blog demo Rate Topic: -----

#1 User is offline   mocapapa 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 428
  • Joined: 04-January 09
  • Location:Tokyo, JAPAN

Posted 19 February 2009 - 06:45 AM

This is not a big widget, but a very simple one.

* Copy following code and save as `blog/protected/components/Links.php`.
~~~
[php]
<?php

class Links extends Portlet
{
        public $title='Links';

        protected function renderContent()
        {
                $this->render('links');
        }
}
~~~

* Copy following code and save as `blog/protected/components/views/links.php`, or make some links whatever you like.
~~~
[php]
<ul>
<li><a href="http://www.yiiframework.com/">Yii</a>
<li><a href="http://www.yiijan.org/">Yiijan</a>
<li><a href="http://phpspot.net/php/codeconv/">PHP code converter</a>
</ul>
~~~

* Add following line to `blog/protected/views/layouts/main.php`.
~~~
[php]
    <?php $this->widget('Recent Comment'); ?>
+    <?php $this->widget('Links'); ?>
~~~

Have fun ;)


[Updated: Feb 22, 2009]
Collection of the enhancements:
http://code.google.c...gdemo-enhanced/
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users