174 lines
4.4 KiB
PHP
Executable File
174 lines
4.4 KiB
PHP
Executable File
<?php
|
|
use yii\helpers\Html;
|
|
use yii\helpers\StringHelper;
|
|
|
|
$firstImage = Yii::$app->abt->getFirstImage($model->description);
|
|
if (empty($firstImage)) {
|
|
$firstImage = Yii::getAlias('@web') . '/img/no-image.png'; // Fallback
|
|
}
|
|
?>
|
|
|
|
<style>
|
|
.modern-post-card {
|
|
background: #fff;
|
|
border-radius: 20px;
|
|
overflow: hidden;
|
|
border: 1px solid #FFDBBB;
|
|
transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
position: relative;
|
|
}
|
|
|
|
.modern-post-card:hover {
|
|
transform: translateY(-10px);
|
|
box-shadow: 0 15px 35px rgba(44, 24, 16, 0.1);
|
|
border-color: #FFC068;
|
|
}
|
|
|
|
.card-img-wrap {
|
|
position: relative;
|
|
height: 200px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card-img-wrap img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
transition: transform 0.6s ease;
|
|
}
|
|
|
|
.modern-post-card:hover .card-img-wrap img {
|
|
transform: scale(1.1);
|
|
}
|
|
|
|
.card-cat-badge {
|
|
position: absolute;
|
|
top: 15px;
|
|
left: 15px;
|
|
background: rgba(142, 29, 29, 0.9);
|
|
color: #fff;
|
|
padding: 4px 15px;
|
|
border-radius: 50px;
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
z-index: 2;
|
|
}
|
|
|
|
.modern-card-body {
|
|
padding: 25px;
|
|
flex-grow: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.card-meta-top {
|
|
display: flex;
|
|
gap: 15px;
|
|
margin-bottom: 12px;
|
|
font-size: 12px;
|
|
color: #888;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.card-meta-top i {
|
|
color: #FFC068;
|
|
margin-right: 4px;
|
|
}
|
|
|
|
.modern-card-title {
|
|
font-size: 18px;
|
|
font-weight: 800;
|
|
line-height: 1.4;
|
|
margin-bottom: 15px;
|
|
color: #2c1810;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
transition: color 0.3s ease;
|
|
}
|
|
|
|
.modern-post-card:hover .modern-card-title {
|
|
color: #8e1d1d;
|
|
}
|
|
|
|
.card-excerpt {
|
|
font-size: 14px;
|
|
color: #666;
|
|
line-height: 1.6;
|
|
margin-bottom: 20px;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card-footer-action {
|
|
margin-top: auto;
|
|
padding-top: 15px;
|
|
border-top: 1px solid #f5f5f5;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.read-more-link {
|
|
font-weight: 700;
|
|
font-size: 13px;
|
|
color: #8e1d1d;
|
|
text-decoration: none !important;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 5px;
|
|
}
|
|
|
|
.read-more-link::after {
|
|
content: '→';
|
|
transition: transform 0.3s ease;
|
|
}
|
|
|
|
.modern-post-card:hover .read-more-link::after {
|
|
transform: translateX(5px);
|
|
}
|
|
|
|
.view-count {
|
|
font-size: 12px;
|
|
color: #bbb;
|
|
}
|
|
</style>
|
|
|
|
<div class="col-lg-4 col-md-6 mb-4 wow fadeInUp">
|
|
<div class="modern-post-card">
|
|
<div class="card-img-wrap">
|
|
<span class="card-cat-badge"><?= $model->cmsCategory->name ?></span>
|
|
<?= Html::img($firstImage, ['alt' => $model->name]) ?>
|
|
</div>
|
|
|
|
<div class="modern-card-body">
|
|
<div class="card-meta-top">
|
|
<span><i class="fa fa-calendar-alt"></i> <?= Yii::$app->formatter->asDate($model->publish_at) ?></span>
|
|
<span><i class="fa fa-user"></i> <?= StringHelper::truncate($model->createdBy->name, 15) ?></span>
|
|
</div>
|
|
|
|
<?= Html::a($model->name, ['/post/view', 'id' => $model->id, 'slug' => Yii::$app->abt->simpleSlug($model->name)], [
|
|
'class' => 'modern-card-title',
|
|
'title' => $model->name
|
|
]) ?>
|
|
|
|
<p class="card-excerpt">
|
|
<?= strip_tags($model->description) ?>
|
|
</p>
|
|
|
|
<div class="card-footer-action">
|
|
<?= Html::a('อ่านเพิ่มเติม', ['/post/view', 'id' => $model->id, 'slug' => Yii::$app->abt->simpleSlug($model->name)], ['class' => 'read-more-link']) ?>
|
|
<span class="view-count"><i class="fa fa-eye mr-1"></i> <?= number_format($model->hit) ?></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|