360 lines
15 KiB
PHP
360 lines
15 KiB
PHP
<?php
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
$db = getDB();
|
|
|
|
// Get category filter
|
|
$catSlug = isset($_GET['cat']) ? trim($_GET['cat']) : '';
|
|
$page = max(1, intval($_GET['page'] ?? 1));
|
|
$offset = ($page - 1) * POSTS_PER_PAGE;
|
|
|
|
// Build query
|
|
$where = "WHERE p.status = 'published'";
|
|
$params = [];
|
|
|
|
if ($catSlug !== '') {
|
|
$where .= " AND c.slug = :cat";
|
|
$params[':cat'] = $catSlug;
|
|
}
|
|
|
|
// Count total
|
|
$countSql = "SELECT COUNT(*) FROM blog_posts p LEFT JOIN blog_categories c ON p.category_id = c.id $where";
|
|
$stmt = $db->prepare($countSql);
|
|
$stmt->execute($params);
|
|
$totalPosts = (int)$stmt->fetchColumn();
|
|
$totalPages = max(1, ceil($totalPosts / POSTS_PER_PAGE));
|
|
|
|
// Fetch posts
|
|
$sql = "SELECT p.*, c.name AS category_name, c.slug AS category_slug
|
|
FROM blog_posts p
|
|
LEFT JOIN blog_categories c ON p.category_id = c.id
|
|
$where
|
|
ORDER BY p.published_at DESC
|
|
LIMIT :limit OFFSET :offset";
|
|
$stmt = $db->prepare($sql);
|
|
foreach ($params as $k => $v) {
|
|
$stmt->bindValue($k, $v, PDO::PARAM_STR);
|
|
}
|
|
$stmt->bindValue(':limit', POSTS_PER_PAGE, PDO::PARAM_INT);
|
|
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
|
$stmt->execute();
|
|
$posts = $stmt->fetchAll();
|
|
|
|
// Fetch categories for sidebar
|
|
$categories = $db->query("SELECT c.*, COUNT(p.id) AS post_count
|
|
FROM blog_categories c
|
|
LEFT JOIN blog_posts p ON c.id = p.category_id AND p.status = 'published'
|
|
GROUP BY c.id
|
|
ORDER BY c.name")->fetchAll();
|
|
|
|
// Current category name
|
|
$currentCatName = '';
|
|
if ($catSlug !== '') {
|
|
foreach ($categories as $cat) {
|
|
if ($cat['slug'] === $catSlug) {
|
|
$currentCatName = $cat['name'];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
$pageTitle = $currentCatName ? e($currentCatName) . ' - Blog TRIMAPE' : 'Blog - TRIMAPE | Excelencia en Mantenimientos';
|
|
$pageDesc = $currentCatName
|
|
? 'Artículos sobre ' . e($currentCatName) . ' en el blog de TRIMAPE.'
|
|
: 'Artículos sobre mantenimiento industrial, eficiencia energética y más. Blog de TRIMAPE.';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100..900&display=swap" rel="stylesheet">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
<title><?= $pageTitle ?></title>
|
|
<meta name="description" content="<?= e($pageDesc) ?>">
|
|
<link rel="icon" href="<?= SITE_URL ?>/assets/img/favico.png">
|
|
<link rel="icon" href="<?= SITE_URL ?>/assets/img/trimape-logo-512-150x150.png" sizes="32x32">
|
|
<link rel="icon" href="<?= SITE_URL ?>/assets/img/trimape-logo-512-300x300.png" sizes="192x192">
|
|
<link rel="apple-touch-icon" href="<?= SITE_URL ?>/assets/img/trimape-logo-512-300x300.png">
|
|
|
|
<meta property="og:title" content="<?= e($pageTitle) ?>">
|
|
<meta property="og:description" content="<?= e($pageDesc) ?>">
|
|
<meta property="og:type" content="website">
|
|
<meta property="og:url" content="<?= BLOG_URL ?>">
|
|
<meta property="og:image" content="<?= SITE_URL ?>/assets/img/trimape-1200.webp">
|
|
|
|
<?php include dirname(__DIR__) . '/css-columna.htm'; ?>
|
|
<style>
|
|
.hero { position: relative; width: 100%; height: 50vh; overflow: hidden; }
|
|
.hero .imgback { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; }
|
|
|
|
.blog-card {
|
|
border: none;
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
|
box-shadow: 0 2px 12px rgba(0,0,0,0.08);
|
|
}
|
|
.blog-card:hover {
|
|
transform: translateY(-8px);
|
|
box-shadow: 0 16px 40px rgba(10, 29, 59, 0.18);
|
|
}
|
|
.blog-card .card-img-wrap {
|
|
overflow: hidden;
|
|
height: 220px;
|
|
}
|
|
.blog-card .card-img-top {
|
|
height: 100%;
|
|
object-fit: cover;
|
|
transition: transform 0.5s ease;
|
|
}
|
|
.blog-card:hover .card-img-top {
|
|
transform: scale(1.08);
|
|
}
|
|
.blog-card .card-body { padding: 1.5rem; }
|
|
.blog-card .badge-cat {
|
|
background: linear-gradient(135deg, #0e55bb, #1186cc);
|
|
font-size: 0.7rem;
|
|
letter-spacing: 0.5px;
|
|
text-transform: uppercase;
|
|
padding: 5px 12px;
|
|
border-radius: 20px;
|
|
}
|
|
.blog-card .card-title {
|
|
font-size: 1.05rem;
|
|
font-weight: 700;
|
|
color: #0a1d3b;
|
|
line-height: 1.4;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
.blog-card .card-text {
|
|
font-size: 0.875rem;
|
|
color: #555;
|
|
line-height: 1.6;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 3;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
.blog-card .card-meta {
|
|
font-size: 0.75rem;
|
|
color: #888;
|
|
}
|
|
.blog-card .read-more {
|
|
color: #1186cc;
|
|
font-weight: 600;
|
|
font-size: 0.85rem;
|
|
text-decoration: none;
|
|
transition: color 0.2s;
|
|
}
|
|
.blog-card .read-more:hover { color: #0e55bb; }
|
|
|
|
.cat-sidebar .list-group-item {
|
|
border: none;
|
|
padding: 10px 16px;
|
|
font-size: 0.9rem;
|
|
border-radius: 8px !important;
|
|
margin-bottom: 4px;
|
|
transition: all 0.2s;
|
|
}
|
|
.cat-sidebar .list-group-item:hover,
|
|
.cat-sidebar .list-group-item.active {
|
|
background: linear-gradient(135deg, #0e55bb, #1186cc);
|
|
color: #fff;
|
|
}
|
|
.cat-sidebar .list-group-item.active .badge {
|
|
background: rgba(255,255,255,0.25) !important;
|
|
}
|
|
|
|
.pagination .page-link {
|
|
border: none;
|
|
color: #0a1d3b;
|
|
font-weight: 600;
|
|
border-radius: 8px !important;
|
|
margin: 0 3px;
|
|
}
|
|
.pagination .page-item.active .page-link {
|
|
background: linear-gradient(135deg, #0e55bb, #1186cc);
|
|
color: #fff;
|
|
}
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 80px 20px;
|
|
}
|
|
.empty-state svg {
|
|
width: 80px;
|
|
height: 80px;
|
|
color: #ccc;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
a.blog-link { text-decoration: none; color: inherit; }
|
|
a.blog-link:hover { color: inherit; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<?php include dirname(__DIR__) . '/menu-general.htm'; ?>
|
|
|
|
<!-- Hero -->
|
|
<div class="hero" id="hero">
|
|
<video autoplay loop muted playsinline class="w-100 imgback">
|
|
<source src="<?= SITE_URL ?>/assets/videos/obra-civil-1.webm" type="video/webm">
|
|
</video>
|
|
<div class="container position-relative d-flex flex-column justify-content-center align-items-center h-100">
|
|
<div class="text-center text-white">
|
|
<h1 class="mb-1 pt-5 texto-sombra fw-bold z-2">BLOG</h1>
|
|
<p class="texto-sombra fw-bold z-2">TRIMAPE | EXCELENCIA EN MANTENIMIENTOS</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Breadcrumbs -->
|
|
<div class="container-fluid text-uppercase">
|
|
<div class="container py-4">
|
|
<nav style="--bs-breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='currentColor'/%3E%3C/svg%3E");" aria-label="breadcrumb">
|
|
<ol class="breadcrumb texto-bread">
|
|
<li class="breadcrumb-item"><a href="<?= SITE_URL ?>">Portada</a></li>
|
|
<?php if ($currentCatName): ?>
|
|
<li class="breadcrumb-item"><a href="<?= BLOG_URL ?>">Blog</a></li>
|
|
<li class="breadcrumb-item active" aria-current="page"><?= e($currentCatName) ?></li>
|
|
<?php else: ?>
|
|
<li class="breadcrumb-item active" aria-current="page">Blog</li>
|
|
<?php endif; ?>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Blog Content -->
|
|
<div class="container pb-5">
|
|
<div class="row">
|
|
<!-- Posts -->
|
|
<div class="col-12 col-lg-8">
|
|
<?php if ($currentCatName): ?>
|
|
<h2 class="fw-bold mb-4" style="color: #0a1d3b;"><?= e($currentCatName) ?></h2>
|
|
<?php endif; ?>
|
|
|
|
<?php if (empty($posts)): ?>
|
|
<div class="empty-state">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M12 7.5h1.5m-1.5 3h1.5m-7.5 3h7.5m-7.5 3h7.5m3-9h3.375c.621 0 1.125.504 1.125 1.125V18a2.25 2.25 0 01-2.25 2.25M16.5 7.5V18a2.25 2.25 0 002.25 2.25M16.5 7.5V4.875c0-.621-.504-1.125-1.125-1.125H4.125C3.504 3.75 3 4.254 3 4.875V18a2.25 2.25 0 002.25 2.25h13.5M6 7.5h3v3H6v-3z" />
|
|
</svg>
|
|
<h4 class="fw-bold" style="color: #0a1d3b;">Próximamente</h4>
|
|
<p class="text-muted">Estamos preparando contenido increíble para ti. ¡Vuelve pronto!</p>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="row g-4">
|
|
<?php foreach ($posts as $post): ?>
|
|
<div class="col-12 col-md-6">
|
|
<a href="<?= BLOG_URL ?>/<?= e($post['slug']) ?>" class="blog-link">
|
|
<div class="card blog-card h-100">
|
|
<div class="card-img-wrap">
|
|
<?php if ($post['cover_image']): ?>
|
|
<img src="<?= e($post['cover_image']) ?>" class="card-img-top" alt="<?= e($post['title']) ?>">
|
|
<?php else: ?>
|
|
<div class="card-img-top d-flex align-items-center justify-content-center" style="background: linear-gradient(135deg, #0a1d3b, #1186cc); height: 100%;">
|
|
<img src="<?= SITE_URL ?>/assets/img/trimape-logo-512-300x300.png" alt="TRIMAPE" style="width: 80px; opacity: 0.5;">
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="card-body d-flex flex-column">
|
|
<?php if ($post['category_name']): ?>
|
|
<span class="badge badge-cat align-self-start mb-2"><?= e($post['category_name']) ?></span>
|
|
<?php endif; ?>
|
|
<h5 class="card-title"><?= e($post['title']) ?></h5>
|
|
<p class="card-text flex-grow-1"><?= e($post['excerpt'] ?: truncate($post['content'])) ?></p>
|
|
<div class="d-flex justify-content-between align-items-center mt-3">
|
|
<span class="card-meta">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" class="bi bi-calendar3 me-1" viewBox="0 0 16 16">
|
|
<path d="M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2M1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857z"/>
|
|
<path d="M6.5 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2m3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2m3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2m-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2m3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2m3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2m3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2m-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2m3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2m3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2"/>
|
|
</svg>
|
|
<?= date('d M Y', strtotime($post['published_at'])) ?>
|
|
</span>
|
|
<span class="read-more">Leer más →</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
<?php if ($totalPages > 1): ?>
|
|
<nav class="mt-5 d-flex justify-content-center">
|
|
<ul class="pagination">
|
|
<?php
|
|
$baseUrl = $catSlug ? BLOG_URL . "/categoria/$catSlug" : BLOG_URL;
|
|
?>
|
|
<?php if ($page > 1): ?>
|
|
<li class="page-item">
|
|
<a class="page-link" href="<?= $baseUrl ?>/pagina/<?= $page - 1 ?>">← Anterior</a>
|
|
</li>
|
|
<?php endif; ?>
|
|
|
|
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
|
|
<li class="page-item <?= $i === $page ? 'active' : '' ?>">
|
|
<a class="page-link" href="<?= $i === 1 ? $baseUrl : $baseUrl . '/pagina/' . $i ?>"><?= $i ?></a>
|
|
</li>
|
|
<?php endfor; ?>
|
|
|
|
<?php if ($page < $totalPages): ?>
|
|
<li class="page-item">
|
|
<a class="page-link" href="<?= $baseUrl ?>/pagina/<?= $page + 1 ?>">Siguiente →</a>
|
|
</li>
|
|
<?php endif; ?>
|
|
</ul>
|
|
</nav>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- Sidebar -->
|
|
<div class="col-12 col-lg-4 mt-4 mt-lg-0">
|
|
<div class="sticky-top" style="top: 100px;">
|
|
<!-- Categories -->
|
|
<div class="card border-0 shadow-sm mb-4" style="border-radius: 12px;">
|
|
<div class="card-body cat-sidebar">
|
|
<h6 class="fw-bold text-uppercase mb-3" style="color: #0a1d3b; letter-spacing: 1px; font-size: 0.8rem;">Categorías</h6>
|
|
<div class="list-group list-group-flush">
|
|
<a href="<?= BLOG_URL ?>" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center <?= $catSlug === '' ? 'active' : '' ?>">
|
|
Todas
|
|
<span class="badge bg-secondary rounded-pill"><?= $totalPosts ?></span>
|
|
</a>
|
|
<?php foreach ($categories as $cat): ?>
|
|
<a href="<?= BLOG_URL ?>/categoria/<?= e($cat['slug']) ?>"
|
|
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center <?= $catSlug === $cat['slug'] ? 'active' : '' ?>">
|
|
<?= e($cat['name']) ?>
|
|
<span class="badge bg-secondary rounded-pill"><?= $cat['post_count'] ?></span>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- CTA -->
|
|
<div class="card border-0 text-white text-center p-4" style="border-radius: 12px; background: linear-gradient(135deg, #0a1d3b 0%, #0e55bb 50%, #1186cc 100%);">
|
|
<div class="card-body">
|
|
<h5 class="fw-bold mb-3">¿Necesitas mantenimiento industrial?</h5>
|
|
<p class="mb-3" style="font-size: 0.9rem; opacity: 0.9;">Contáctanos y recibe una cotización sin compromiso.</p>
|
|
<a href="<?= SITE_URL ?>/contacto" class="btn px-4 py-2 fw-bold" style="background-color: rgb(255, 102, 0); color: white; border-radius: 8px;">CONTACTO</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include dirname(__DIR__) . '/contacto-div.htm'; ?>
|
|
<?php include dirname(__DIR__) . '/footer.htm'; ?>
|
|
<?php include dirname(__DIR__) . '/footer-scripts.htm'; ?>
|
|
</body>
|
|
</html>
|