Add Project-Pro Blog module with initial SQL setup, CSS styles, and template files
- Created SQL installation scripts for categories and posts tables. - Added uninstall scripts to drop the created tables. - Introduced CSS styles for blog layout, including responsive design for posts and categories. - Implemented PHP redirection in index files to prevent direct access. - Developed Smarty templates for blog category tree, post list, and individual post details. - Ensured proper caching headers in PHP files to enhance performance.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
{**
|
||||
* Project-Pro Blog — partial: drzewo kategorii (rekurencyjne)
|
||||
*
|
||||
* Parametry:
|
||||
* $tree — wynik BlogCategory::getCategoryTree() z URL-ami
|
||||
* $current_cat — aktualny obiekt BlogCategory lub null
|
||||
*}
|
||||
|
||||
{if $tree}
|
||||
<ul class="blog-cat-tree">
|
||||
{foreach from=$tree item=node}
|
||||
{assign var="cat" value=$node.category}
|
||||
{assign var="children" value=$node.children}
|
||||
{assign var="isActive" value=($current_cat && $current_cat->id == $cat.id_category)}
|
||||
{assign var="hasActive" value=false}
|
||||
|
||||
{* Sprawdź czy aktywna kategoria jest wśród dzieci (do automatycznego rozwinięcia) *}
|
||||
{if $current_cat && $children}
|
||||
{foreach from=$children item=child}
|
||||
{if $child.category.id_category == $current_cat->id}
|
||||
{assign var="hasActive" value=true}
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/if}
|
||||
|
||||
<li class="blog-cat-item{if $isActive} is-active{/if}{if $children} has-children{/if}">
|
||||
|
||||
{if $children}
|
||||
<span class="blog-cat-toggle" data-target="#cat-sub-{$cat.id_category}"
|
||||
title="{if $isActive || $hasActive}{l s='Zwiń' mod='projectproblog'}{else}{l s='Rozwiń' mod='projectproblog'}{/if}">
|
||||
{if $isActive || $hasActive}▼{else}►{/if}
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
<a href="{$cat.url|escape:'html':'UTF-8'}"
|
||||
class="blog-cat-link{if $isActive} active{/if}">
|
||||
{$cat.name|escape:'html':'UTF-8'}
|
||||
</a>
|
||||
|
||||
{if $children}
|
||||
<ul id="cat-sub-{$cat.id_category}"
|
||||
class="{if $isActive || $hasActive}open{/if}">
|
||||
{include
|
||||
file='module:projectproblog/views/templates/front/_category-tree.tpl'
|
||||
tree=$children
|
||||
current_cat=$current_cat}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
8
modules/projectproblog/views/templates/front/index.php
Normal file
8
modules/projectproblog/views/templates/front/index.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
header("Location: ../");
|
||||
exit;
|
||||
140
modules/projectproblog/views/templates/front/list.tpl
Normal file
140
modules/projectproblog/views/templates/front/list.tpl
Normal file
@@ -0,0 +1,140 @@
|
||||
{**
|
||||
* Project-Pro Blog — strona listy wpisów
|
||||
*}
|
||||
{extends file='layouts/layout-full-width.tpl'}
|
||||
|
||||
{block name='content'}
|
||||
<section id="blog-wrap" class="container">
|
||||
<div class="row">
|
||||
|
||||
{* ====================================================
|
||||
LEWA KOLUMNA — drzewo kategorii
|
||||
==================================================== *}
|
||||
<aside id="blog-sidebar" class="col-md-3">
|
||||
<div class="blog-cats-widget">
|
||||
<h4>{l s='Kategorie' mod='projectproblog'}</h4>
|
||||
|
||||
<a href="{$blog_url|escape:'html':'UTF-8'}"
|
||||
class="blog-cat-link{if !$blog_current_cat} active{/if}"
|
||||
style="display:block;margin-bottom:.5rem;">
|
||||
{l s='Wszystkie wpisy' mod='projectproblog'}
|
||||
</a>
|
||||
|
||||
{include
|
||||
file='module:projectproblog/views/templates/front/_category-tree.tpl'
|
||||
tree=$blog_category_tree
|
||||
current_cat=$blog_current_cat}
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{* ====================================================
|
||||
PRAWA KOLUMNA — lista wpisów + paginacja
|
||||
==================================================== *}
|
||||
<div id="blog-content" class="col-md-9">
|
||||
|
||||
<h1 class="blog-list-title">
|
||||
{if $blog_current_cat}
|
||||
{$blog_current_cat->name|escape:'html':'UTF-8'}
|
||||
{else}
|
||||
{l s='Blog' mod='projectproblog'}
|
||||
{/if}
|
||||
</h1>
|
||||
|
||||
{if $blog_posts}
|
||||
|
||||
<div class="blog-grid">
|
||||
{foreach from=$blog_posts item=post}
|
||||
<div class="blog-grid-item">
|
||||
<article class="blog-card">
|
||||
|
||||
{if $post.thumbnail_url}
|
||||
<a href="{$post.url|escape:'html':'UTF-8'}" class="blog-card__thumb">
|
||||
<img src="{$post.thumbnail_url|escape:'html':'UTF-8'}"
|
||||
alt="{$post.title|escape:'html':'UTF-8'}"
|
||||
loading="lazy">
|
||||
</a>
|
||||
{/if}
|
||||
|
||||
<div class="blog-card__body">
|
||||
<h2 class="blog-card__title">
|
||||
<a href="{$post.url|escape:'html':'UTF-8'}">
|
||||
{$post.title|escape:'html':'UTF-8'}
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
{if $post.intro}
|
||||
<div class="blog-card__intro">
|
||||
{$post.intro|strip_tags|truncate:180:'…'}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="blog-card__footer">
|
||||
<span class="blog-card__date">
|
||||
{$post.date_add|date_format:'%d.%m.%Y'}
|
||||
</span>
|
||||
<a href="{$post.url|escape:'html':'UTF-8'}" class="blog-card__more">
|
||||
{l s='Czytaj więcej' mod='projectproblog'} ›
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
{* ---- Paginacja ---- *}
|
||||
{if $blog_pagination && $blog_pages_count > 1}
|
||||
<nav class="blog-pagination" aria-label="{l s='Strony' mod='projectproblog'}">
|
||||
|
||||
{if $blog_pagination.prev}
|
||||
<a href="{$blog_pagination.prev|escape:'html':'UTF-8'}" aria-label="{l s='Poprzednia' mod='projectproblog'}">«</a>
|
||||
{else}
|
||||
<span class="disabled">«</span>
|
||||
{/if}
|
||||
|
||||
{foreach from=$blog_pagination.pages item=pg}
|
||||
{if $pg.current}
|
||||
<span class="current">{$pg.page}</span>
|
||||
{else}
|
||||
<a href="{$pg.url|escape:'html':'UTF-8'}">{$pg.page}</a>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
{if $blog_pagination.next}
|
||||
<a href="{$blog_pagination.next|escape:'html':'UTF-8'}" aria-label="{l s='Następna' mod='projectproblog'}">»</a>
|
||||
{else}
|
||||
<span class="disabled">»</span>
|
||||
{/if}
|
||||
|
||||
</nav>
|
||||
{/if}
|
||||
|
||||
{else}
|
||||
<p class="blog-empty">
|
||||
{l s='Brak wpisów do wyświetlenia.' mod='projectproblog'}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
</div>{* /blog-content *}
|
||||
</div>{* /row *}
|
||||
</section>
|
||||
{/block}
|
||||
|
||||
{block name='javascript_bottom' append}
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
/* Rozwijanie/zwijanie podkategorii */
|
||||
document.querySelectorAll('.blog-cat-toggle').forEach(function (toggle) {
|
||||
toggle.addEventListener('click', function () {
|
||||
var targetId = this.getAttribute('data-target');
|
||||
var sub = document.querySelector(targetId);
|
||||
if (!sub) { return; }
|
||||
var isOpen = sub.classList.toggle('open');
|
||||
this.innerHTML = isOpen ? '▼' : '►';
|
||||
});
|
||||
});
|
||||
}());
|
||||
</script>
|
||||
{/block}
|
||||
134
modules/projectproblog/views/templates/front/post.tpl
Normal file
134
modules/projectproblog/views/templates/front/post.tpl
Normal file
@@ -0,0 +1,134 @@
|
||||
{**
|
||||
* Project-Pro Blog — strona szczegółu wpisu
|
||||
*}
|
||||
{extends file='layouts/layout-full-width.tpl'}
|
||||
|
||||
{block name='content'}
|
||||
<section id="blog-wrap" class="container">
|
||||
<div class="row">
|
||||
|
||||
{* ====================================================
|
||||
LEWA KOLUMNA — drzewo kategorii
|
||||
==================================================== *}
|
||||
<aside id="blog-sidebar" class="col-md-3">
|
||||
<div class="blog-cats-widget">
|
||||
<h4>{l s='Kategorie' mod='projectproblog'}</h4>
|
||||
|
||||
<a href="{$blog_url|escape:'html':'UTF-8'}"
|
||||
class="blog-cat-link"
|
||||
style="display:block;margin-bottom:.5rem;">
|
||||
{l s='Wszystkie wpisy' mod='projectproblog'}
|
||||
</a>
|
||||
|
||||
{include
|
||||
file='module:projectproblog/views/templates/front/_category-tree.tpl'
|
||||
tree=$blog_category_tree
|
||||
current_cat=$blog_current_cat}
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{* ====================================================
|
||||
PRAWA KOLUMNA — treść wpisu
|
||||
==================================================== *}
|
||||
<div id="blog-content" class="col-md-9">
|
||||
|
||||
<article class="blog-post" itemscope itemtype="https://schema.org/BlogPosting">
|
||||
|
||||
{* ---- Nagłówek ---- *}
|
||||
<header class="blog-post-header">
|
||||
|
||||
<h1 class="blog-post-title" itemprop="headline">
|
||||
{$blog_post->title|escape:'html':'UTF-8'}
|
||||
</h1>
|
||||
|
||||
<div class="blog-post-meta">
|
||||
<span>
|
||||
<time datetime="{$blog_post->date_add|date_format:'%Y-%m-%d'}" itemprop="datePublished">
|
||||
{$blog_post->date_add|date_format:'%d.%m.%Y'}
|
||||
</time>
|
||||
</span>
|
||||
|
||||
{if $blog_show_updated}
|
||||
<span>
|
||||
{l s='Aktualizacja:' mod='projectproblog'}
|
||||
<time datetime="{$blog_post->date_upd|date_format:'%Y-%m-%d'}" itemprop="dateModified">
|
||||
{$blog_post->date_upd|date_format:'%d.%m.%Y'}
|
||||
</time>
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
{if $blog_post_cats}
|
||||
<span class="blog-post-cats">
|
||||
{foreach from=$blog_post_cats item=cat}
|
||||
<a href="{$cat.url|escape:'html':'UTF-8'}"
|
||||
class="cat-badge"
|
||||
itemprop="articleSection">
|
||||
{$cat.name|escape:'html':'UTF-8'}
|
||||
</a>
|
||||
{/foreach}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
</header>
|
||||
|
||||
{* ---- Miniaturka ---- *}
|
||||
{if $blog_thumbnail}
|
||||
<figure class="blog-post-thumb">
|
||||
<img src="{$blog_thumbnail|escape:'html':'UTF-8'}"
|
||||
alt="{$blog_post->title|escape:'html':'UTF-8'}"
|
||||
itemprop="image">
|
||||
</figure>
|
||||
{/if}
|
||||
|
||||
{* ---- Wstęp ---- *}
|
||||
{if $blog_post->intro}
|
||||
<div class="blog-post-intro" itemprop="description">
|
||||
{$blog_post->intro nofilter}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{* ---- Treść ---- *}
|
||||
{if $blog_post->content}
|
||||
<div class="blog-post-content" itemprop="articleBody">
|
||||
{$blog_post->content nofilter}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{* ---- Powrót do listy / kategorii ---- *}
|
||||
<div class="blog-post-back">
|
||||
{if $blog_primary_cat}
|
||||
<a href="{$blog_primary_cat.url|escape:'html':'UTF-8'}">
|
||||
← {l s='Wróć do kategorii' mod='projectproblog'}:
|
||||
{$blog_primary_cat.name|escape:'html':'UTF-8'}
|
||||
</a>
|
||||
·
|
||||
{/if}
|
||||
<a href="{$blog_url|escape:'html':'UTF-8'}">
|
||||
{l s='Wszystkie wpisy' mod='projectproblog'}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</article>
|
||||
|
||||
</div>{* /blog-content *}
|
||||
</div>{* /row *}
|
||||
</section>
|
||||
{/block}
|
||||
|
||||
{block name='javascript_bottom' append}
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
document.querySelectorAll('.blog-cat-toggle').forEach(function (toggle) {
|
||||
toggle.addEventListener('click', function () {
|
||||
var targetId = this.getAttribute('data-target');
|
||||
var sub = document.querySelector(targetId);
|
||||
if (!sub) { return; }
|
||||
var isOpen = sub.classList.toggle('open');
|
||||
this.innerHTML = isOpen ? '▼' : '►';
|
||||
});
|
||||
});
|
||||
}());
|
||||
</script>
|
||||
{/block}
|
||||
Reference in New Issue
Block a user