4時間目
1.返信するの横に詳細を見るのリンク追加。
<?php echo link_to("詳細を見る", "@commentdatail?id=".$comment->getId())?>
2.default/datailでコメント詳細ページ表示action側
public function executeDatail()
{
//GETで渡されてくるコメントIDとか
$id = $this->getRequestParameter("id");
$this->comment = CommentPeer::retrieveByPK($id);
$this->photo = $this->getRequestParameter("photo");
return sfView::SUCCESS;
}
datilSussess.php
<div class="box">
<?php echo $comment->getNickname();?>の投稿<br>
<?php if($comment->getPhoto()):?><br>
<?php echo image_tag("/images/comment/".$comment->getPhoto());?><br><br>
<?php endif;?>
<?php if($comment->getPhoto2()):?><br>
<?php echo image_tag("/images/comments2/".$comment->getPhoto2());?><br><br>
<?php endif;?>
<?php echo $comment->getContent();?><br>
<?php echo $comment->getCreatedAt();?><br>
</div>
3.commentテーブルにaccess_cntカラム追加ALTER TABLE comment ADD access_cnt int;
4.詳細ページを開くごとにアクセス数に+1させて、
shared/access_cntコンポーネントで、アクセス数多い順のコメント5件表示
午前中にreply_cntでやったところらしい。
CommentPeer
static public function retrieveAccessRanking() {
$c = new Criteria();
$c->addDescendingOrderByColumn(self::ACCESS_CNT);
$c->setlimit(5);
return self::doSelect($c);
}
action
public function executeDatail()
{
//GETで渡されてくるコメントID
$id = $this->getRequestParameter("id");
$this->comment = CommentPeer::retrieveByPK($id);
$this->photo = $this->getRequestParameter("photo");
//現在のアクセスカウントを取得
$access_cnt = $this->comment->getAccessCnt();
//取得したアクセスカウントに+1をセット
$this->comment->setAccessCnt($access_cnt + 1);
//更新
$this->comment->save();
return sfView::SUCCESS;
}
5時間目上記答え合わせ。
6時間目
exerciseモジュール作成。indexからstage2へgetとpostの処理を再度勉強。
自信が無い人はstage10ぐらいまでgetとpostで送り続けるのをやろう。
これができないと今後ついていけなくなるそうです。
0 件のコメント:
コメントを投稿