1
0

Improved Blogpost view

This commit is contained in:
2014-07-12 16:42:24 +02:00
parent abcc540713
commit 14f3d5df3b
8 changed files with 245 additions and 158 deletions

View File

@@ -0,0 +1,14 @@
<?php
class BlogLink extends CWidget {
public $date;
public $caption = '';
public $link = '';
public function run() {
if ($this->date == null)
$this->date = new DateTime('2000-01-01');
$this->render('blogLink');
}
}

View File

@@ -0,0 +1,10 @@
<?php
/* @var $this BlogLink */
?>
<div class="row collHeader collHeaderLinkParent">
<div class="collHeaderSpan-front"><?php echo $this->date->format('d.m.Y'); ?></div>
<div class="collHeaderSpan"><?php echo $this->caption; ?></div>
<div class="collHeaderSpan-drop"><i class="icon-file" ></i></div>
<a class="collHeaderLink" href="<?php echo $this->link; ?>">&nbsp;</a>
</div>

View File

@@ -125,10 +125,16 @@ class BlogPostController extends MSController
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('BlogPost');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
$criteria = new CDbCriteria;
$criteria->order = "Date DESC";
$all = BlogPost::model()->findAll($criteria);
$this->render('index',
[
'blogposts' => $all,
]
);
}
public function actionAjaxMarkdownPreview() {

View File

@@ -96,4 +96,11 @@ class BlogPost extends CActiveRecord
{
return parent::model($className);
}
/**
* @return string
*/
public function getLink() {
return '/blog/' . $this->ID;
}
}

View File

@@ -49,7 +49,7 @@ or <b>=</b>) at the beginning of each of your search values to specify how the c
'columns'=>array(
'ID',
'Date',
'Content',
'Title',
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),

View File

@@ -1,6 +1,6 @@
<?php
/* @var $this BlogPostController */
/* @var $dataProvider CActiveDataProvider */
/* @var $blogposts BlogPost[] */
?>
<?php
@@ -15,9 +15,22 @@ $this->selectedNav = 'blog';
?>
<h1>Blog Posts</h1>
<div class="container">
<?php $this->widget('bootstrap.widgets.TbListView',array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>
<?php echo MsHtml::pageHeader("Blog", "My personal programming blog"); ?>
<?php
$i = 0;
foreach($blogposts as $blogpost) {
$i++;
$this->widget('BlogLink',
[
'date' => new DateTime($blogpost->Date),
'caption' => $blogpost->Title,
'link' => $blogpost->getLink(),
]);
}
?>
</div>

View File

@@ -15,8 +15,6 @@ $this->breadcrumbs = array(
<div class="container">
<h1>View BlogPost #<?php echo $model->ID; ?></h1>
<div class="well markdownOwner" id="markdownAjaxContent">
<?php echo ParsedownHelper::parse($model->Content); ?>
</div>