diff options
author | xue <> | 2006-05-30 17:30:40 +0000 |
---|---|---|
committer | xue <> | 2006-05-30 17:30:40 +0000 |
commit | fd1c45c54585b020ef528586599a1fe56e9ee1f7 (patch) | |
tree | 296fc1df232024a8ec94bb61a22bff42ab050a23 /demos/blog/protected/Portlets | |
parent | 117813a0323e5669a2cd64598119fb81dd02e979 (diff) |
Added recent comments portlet.
Diffstat (limited to 'demos/blog/protected/Portlets')
-rw-r--r-- | demos/blog/protected/Portlets/CommentPortlet.php | 39 | ||||
-rw-r--r-- | demos/blog/protected/Portlets/CommentPortlet.tpl | 15 |
2 files changed, 54 insertions, 0 deletions
diff --git a/demos/blog/protected/Portlets/CommentPortlet.php b/demos/blog/protected/Portlets/CommentPortlet.php new file mode 100644 index 00000000..4147d6d3 --- /dev/null +++ b/demos/blog/protected/Portlets/CommentPortlet.php @@ -0,0 +1,39 @@ +<?php
+/**
+ * CommentPortlet class file
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ */
+
+Prado::using('Application.Portlets.Portlet');
+
+/**
+ * CommentPortlet class
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ */
+class CommentPortlet extends Portlet
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $comments=$this->Application->getModule('data')->queryComments('','ORDER BY create_time DESC','LIMIT 10');
+ foreach($comments as $comment)
+ {
+ $comment->ID=$this->Service->constructUrl('Posts.ViewPost',array('id'=>$comment->PostID)).'#c'.$comment->ID;
+ if(strlen($comment->Content)>40)
+ $comment->Content=substr($comment->Content,0,40).' ...';
+ }
+ $this->CommentList->DataSource=$comments;
+ $this->CommentList->dataBind();
+ }
+}
+
+?>
\ No newline at end of file diff --git a/demos/blog/protected/Portlets/CommentPortlet.tpl b/demos/blog/protected/Portlets/CommentPortlet.tpl new file mode 100644 index 00000000..cebdabc6 --- /dev/null +++ b/demos/blog/protected/Portlets/CommentPortlet.tpl @@ -0,0 +1,15 @@ +<div class="portlet">
+
+<h2 class="portlet-title">Latest comments</h2>
+
+<div class="portlet-content">
+<com:TBulletedList
+ ID="CommentList"
+ DisplayMode="HyperLink"
+ DataTextField="Content"
+ DataValueField="ID"
+ EnableViewState="false"
+ />
+</div><!-- end of portlet-content -->
+
+</div><!-- end of portlet -->
|