Appearance
Blog
Flow ID: CF-20 | Module(s): blog, Cms domain | Complexity: Medium | Last Updated: 2026-11-13
Business Overview
Full blog system with articles, categories, tags, authors, and moderated comments. Articles link to products bi-directionally. Blog has its own _remap() dispatcher that resolves slugs to categories, tags, or articles.
What customers experience:
/blogor/blog/allmain listing with the first article featured/blog/{article-slug}full article page with related articles, products, comments, author bio/blog/{category-slug}category-filtered article listing/blog/{tag-slug}tag-filtered article listing/blog/blogAuthor/{author-slug}author page with the author's 6 most recent published articles (no pagination)/blog/search/{term}search results (Solr-powered, supports live AJAX search)/blog/rssRSS feed of all published articles
Key business behaviors:
- Publishing (listings): the index, category, tag, author and RSS listings, and the article page's related articles and previous/next links, show only articles with
is_published = trueANDblog_date <= date('Y-m-d')(Adv_blog.php:121, 337, 393, 505-509, 610, 713; related articles:Adv_blog_model.php:492-493). Becauseblog_dateis aDATETIME, today's date compares as today at00:00:00(Known Issue 5). Blog search usesblog_date <= date('Y-m-d H:i:s')instead (Adv_search_model.php:715, 746,Adv_search_model_v2.php:1004, 1035). - Publishing (article page):
blogArticle()answers 404 to a visitor for a draft, and for a published article whoseblog_dateis still in the future (scheduled) until that moment (Adv_blog::isArticleVisible()/isScheduledArticle(),Adv_blog.php:243-246). It comparesblog_datewith the current time, so an article dated today at 14:30 opens at 14:30, while the listings show it from the next day (Known Issue 5). ANULLblog_dateis not a schedule: the page opens, though no listing shows it (Known Issue 6). Only a session carrying the back-office login flagloggedInopens drafts and scheduled articles early (admin preview).Advauth::login()sets it for database and config-file admins (application/libraries/Advauth.php:128, 148), and so does SSO (ecommercen/sso/controllers/AdvSso.php:76); it reaches the storefront through the shared session cookie. Storefront customer login setscustomer_logged_ininstead (ecommercen/eshop/models/Adv_customer_model.php:342), so logged-in customers get the 404 too. The REST read path appliesis_publishedonly, with no date window, so a headless storefront receives a scheduled article (BlogArticle::storefrontRowScope(), Known Issue 7). - Category/author/tag deletion blocked if articles exist
- Optional comments (moderated: pending -> approved/rejected) gated by
OTHER.ENABLE_BLOG_COMMENTSregistry - Blog-product two-way sync configurable (
BLOG_PRODUCT_TWO_WAY_SYNC) - Builder block integration for rich article content via
blogArticleposition - Content embeddings support: product and product list embeds in article body
- Hit counter incremented per article view
- RSS feed with configurable title/description per language via Registry
API Reference
REST Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /rest/cms/blog/article | Guest | List articles (filterable, sortable, paginated) |
| GET | /rest/cms/blog/article/{id} | Guest | Get article by ID |
| POST | /rest/cms/blog/article | Backend (CMS) | Create article (multipart -- banner) |
| POST | /rest/cms/blog/article/{id} | Backend (CMS) | Update article |
| DELETE | /rest/cms/blog/article/{id} | Backend (CMS) | Delete article |
| GET | /rest/cms/blog/author | Guest | List authors |
| POST | /rest/cms/blog/author | Backend (CMS) | Create/update author |
| DELETE | /rest/cms/blog/author/{id} | Backend (CMS) | Delete author |
| GET | /rest/cms/blog/category | Guest | List categories |
| POST | /rest/cms/blog/category | Backend (CMS) | Create/update category |
| DELETE | /rest/cms/blog/category/{id} | Backend (CMS) | Delete category |
| GET | /rest/cms/blog/tag | Guest | List tags |
| POST | /rest/cms/blog/tag | Backend (CMS) | Create/update tag |
| DELETE | /rest/cms/blog/tag/{id} | Backend (CMS) | Delete tag |
| GET | /rest/cms/blog/comment | Guest (approved only) | List comments -- storefront (guest/customer) sees only approved comments; email/status fields and the email filter/sort are withheld |
| POST | /rest/cms/blog/comment | Backend (CMS) | Create/update comment |
| DELETE | /rest/cms/blog/comment/{id} | Backend (CMS) | Delete comment |
Full CRUD for all blog entities with Backend (CMS) auth.
Storefront scoping on comments (guest and authenticated customer -- backend/CMS callers are exempt and see everything): GET /rest/cms/blog/comment (index/item) forces status=approved, and email/status are omitted from the response at every nesting depth (children, parent). GET /rest/cms/blog/comment/{id} (show()) answers 404 for a pending or rejected comment. filter[email] and every email sort form (sort=email, sort=children.email) are denied. The same scoping applies to comments reached via GET /rest/cms/blog/article?with=comments and ?with=comments.children, including its own sort=comments.email denial. A denied filter or sort is dropped silently -- the request still returns 200, just without that parameter's effect, the same as any unrecognised query key.
Legacy Storefront
| URL | Method | Description |
|---|---|---|
/blog or /blog/all | index() | Article listing (9/page, first article featured) |
/blog/{article-slug} | blogArticle($slug) | Single article with related content |
/blog/{category-slug} | blogCategory($slug) | Category listing |
/blog/{tag-slug} | blogTag($slug) | Tag listing |
/blog/blogAuthor/{author-slug} | blogAuthor($slug) | Author page (6 most recent published articles, no pagination) |
/blog/search/{term}/{page} | search() | Full-page search results |
/blog/search/{term} (AJAX) | search() -> liveSearch() | Live autocomplete search |
/blog/rss | rss() | RSS XML feed |
Code Flow
Step 1: URL Routing via _remap()
File: ecommercen/blog/controllers/Adv_blog.php
all: Routes toindex()- Allow-listed action:
_remap()calls a method only when the decoded segment matches an entry ofremapActions()- Default list:
index,blogAuthor,rss,search blogAuthoris how the author page is reached:/blog/blogAuthor/{author-slug}, the URLecommercen/helpers/theme_helper.php:644builds- Matching is case-insensitive, and the method is called with the list's own spelling, only if the method exists
all(item 1) is handled before the allow-list- Any other segment, including protected helpers like
liveSearch()andsearchPage()and inherited methods, falls through to the slug lookups below, then 404
- Default list:
- Category slug match:
blog_category_model->getCategoryBySlug()(cached) ->blogCategory() - Tag slug match:
blog_tags_model->getTagBySlug()(cached) ->blogTag() - Article slug match:
blog_model->getArticleBySlug()(cached) ->blogArticle() - Fallback: 404
Step 2: Article Index
File: ecommercen/blog/controllers/Adv_blog.php::index()
- Pagination: Page number from URL, offset calculated as
(page - 1) * 9 - Query:
blog_model->getBlogsList()withis_published=true, blog_date<=date('Y-m-d') - Featured article: First article on page 1 is shifted to
mainArticle - Sidebar: Categories via
getCategoriesFront(), tags viagetTagsFront() - Hreflang: Language switcher URLs via
lang_uri - Hook:
indexExtras()-- empty by default - Tag rendering:
getBlogListingRelatedTags()for sidebar tags - Render:
blogIndexlayout
Step 3: Single Article Page
File: ecommercen/blog/controllers/Adv_blog.php::blogArticle()
- Fetch:
blog_model->getBlogData($slug, $lang)-- 404 if not found; 404 if unpublished or scheduled, unless the session carries the back-officeloggedInflag (isArticleVisible()) - SEO: Meta tags from article MUI fields
- Hreflang: MUI slug lookup per language
- Content embeddings:
renderBlogContentEmbeddings()-- extracts product/product-list embeds from article description - Products:
renderBlogProducts()-- fetches linked products fromblog_producttable (sorted by priority) - Builder block:
blockBuilder->frontRender()forblogArticleposition usingbuilder_block_id - Related articles:
blog_model->blogRelativeArticles($blogId, $lang)-- the other articles that share at least one of this article's categories, newest first, restricted like the previous/next list (item 9) tois_published = trueandblog_date <= today. The method applies that restriction itself, because its callers pass no conditions (ecommercen/blog/models/Adv_blog_model.php:463-503, restriction at:492-493) - Author data:
blog_author_model->getAuthorRecord()plus categories - Previous/Next:
blog_model->getPreviousNext($blogId, $where)-- the articles either side of this one in the newest-first list of articles that share at least one of its categories, restricted by the caller tois_published = trueandblog_date <= today(Adv_blog_model.php:158-222, conditions atecommercen/blog/controllers/Adv_blog.php:337). An article that is not in that list itself (a draft previewed from the back office, or a published article dated after the start of today) gets no previous/next link (Adv_blog_model.php:209-215) - Slider: Optional slider if
slider_idset - Hook:
blogArticleExtras()-- loads author, categories, related articles, prev/next and slider by default (items 7-10; categories, related articles and prev/next are cached throughpscache) - Events:
blogArticleEvents()-- empty hook for client - Comments:
manageBlogComments($blogId) - Hit counter:
updateArticleHits($blogId)
Articles with no category. The admin blog form requires a category (ecommercen/blog/controllers/Adv_blog_admin.php:436), but Cms\Blog\Article\WriteService::create() writes none (src/Domains/Cms/Blog/Article/WriteService.php:26-45), so an article created through POST /rest/cms/blog/article or the MCP connector's create_article tool has no blog_blog_categories row. Its page renders with no related articles and no previous/next links: both model methods return as soon as the category lookup comes back empty -- [] and ['previous' => null, 'next' => null], the values an article alone in its categories also gets -- without running their second query (Adv_blog_model.php:478-482, :177-182). getPreviousNext() returns before it applies the caller's conditions, so none are left queued on the query builder. Such an article is also absent from every category page and from other articles' related and previous/next lists.
Step 4: Comment Submission and Moderation
File: ecommercen/blog/controllers/Adv_blog.php::manageBlogComments()
- Feature gate:
OTHER.ENABLE_BLOG_COMMENTSregistry setting - POST handling: On form submit, validates
comment,blog_commenter_email,blog_commenter_name - Save:
blog_comments_model->saveComment()-- status defaults topending - Flash: Success message, redirect to same page
- Display:
getBlogComments($blogId, 10)-- only showsapprovedcomments, ordered byentry_date DESC
Admin moderation (ecommercen/blog/controllers/Adv_blog_comments_admin.php):
- List all comments with status filter (approved/rejected/pending), search by content/email/date
- Single and batch status updates both go through
setReviewStatus():setStatus()(Adv_blog_comments_admin.php:97-114) calls it once per comment;batchAction()(Adv_blog_comments_admin.php:116-128) calls it in a loop, once per selected comment id. The model's bulk-update methodbatchUpdateStatus()(Adv_blog_comments_model.php:142-145) is defined but not called by the admin controller. - Pending count badge via
getBlogCommentsCount()(shows "99+" for large queues)
Step 5: Blog Search
File: ecommercen/blog/controllers/Adv_blog.php::search()
- Guard: Empty search term returns 410 Gone
- AJAX path:
liveSearch($term)(protected, called bysearch(), not URL-routable) -- returns JSON results for autocomplete - Page path:
searchPage($term, $pageNumber)(protected, called bysearch(), not URL-routable) -- full rendered search results page - Solr integration: Routes to
search_model(v1) orsearch_model_v2(v2) based onsolrSearch.versionconfig - Results: Paginated articles matching search term, with sidebar categories/tags
Step 6: RSS Feed
File: ecommercen/blog/controllers/Adv_blog.php::rss()
- Config: Title and description from Registry
BLOG.RSSTITLE/BLOG.RSSDESCRIPTION(per language) - Articles: All published articles via
getBlogsList() - Output: XML content type, rendered via
blog/rssview template
Domain Layer
| Component | Path |
|---|---|
| Article Service | src/Domains/Cms/Blog/Article/Service.php |
| Article WriteService | src/Domains/Cms/Blog/Article/WriteService.php |
| Article Entity | src/Domains/Cms/Blog/Article/Repository/Entity.php |
| REST Controllers | src/Rest/Cms/Controllers/BlogArticle.php, BlogCategory.php, BlogTag.php, BlogAuthor.php, BlogComment.php |
| Legacy Controller | ecommercen/blog/controllers/Adv_blog.php |
| Blog Model | ecommercen/blog/models/Adv_blog_model.php (not shown -- main article queries) |
| Comments Model | ecommercen/blog/models/Adv_blog_comments_model.php |
| Product Link Model | ecommercen/blog/models/Adv_blog_product_model.php |
| Author Model | ecommercen/blog/models/Adv_blog_author_model.php |
| Category Model | ecommercen/blog/models/Adv_blog_category_model.php |
| Tags Model | ecommercen/blog/models/Adv_blog_tags_model.php |
| Admin Controllers | Adv_blog_admin.php, Adv_blog_comments_admin.php, Adv_blog_tags_admin.php |
Data Model
blog
| Column | Type | Description |
|---|---|---|
id | int (PK, AI) | Article ID |
blog_author_id | int (FK) | Author reference |
banner_image | varchar(250) | Banner image path |
blog_date | datetime (nullable, default NULL) | Publish date and time; the admin picker sets a date plus HH:mm (application/views/admin/footer_js.php:308-312). Future = scheduled: the listings omit it and its page answers 404 to visitors until then, though the product article blocks list it (Known Issue 4); an article dated later today stays off the listings until the next day (Known Issue 5). NULL is not a schedule: the page opens, but no listing shows it (Known Issue 6). Type set by database/migrations/20241024093212_change_blog_date_to_datetime.php |
is_published | tinyint(1) | Whether article is published |
is_promo | tinyint(1) | Promotional flag |
youtube_video_id | varchar(250) | Embedded YouTube video |
spotify_podcast_id | varchar(250) | Embedded Spotify podcast |
hits | int | View counter |
blog_mui
| Column | Type | Description |
|---|---|---|
id | int (PK, AI) | MUI entry ID |
blog_id | int (FK) | Parent article |
slug | varchar(250) | URL slug |
title | varchar(255) | Article title |
meta_keywords | text | SEO keywords |
meta_description | text | SEO description |
meta_title | text | SEO title |
description | longtext | Full article content (supports content embeddings) |
small_description | text | Excerpt/summary |
lang | varchar(2) | Language code |
blog_comments
| Column | Type | Description |
|---|---|---|
id | int (PK, AI) | Comment ID |
blog_id | int (FK) | Parent article |
email | varchar(255) | Commenter email |
name | varchar(255) | Commenter name |
comment_content | text | Comment text |
entry_date | datetime | Submission timestamp (defaults to current_timestamp()) |
parent_comment_id | int (nullable) | For threaded replies |
status | enum | approved, pending, rejected (default: pending) |
lang | varchar(4) | Language code |
blog_product
| Column | Type | Description |
|---|---|---|
blog_id | int (PK, FK) | Article reference |
product_id | int (PK, FK) | Product reference |
priority | int | Display order (0 = default) |
Supporting Tables
| Table | Purpose |
|---|---|
blog_categories | Category master (banner_image, is_active, ord, parent_id) |
blog_categories_mui | Category translations (title, slug, description, meta fields) |
blog_blog_categories | Article-to-category lookup (blog_id, blog_category_id) |
blog_tags | Tag master (is_active, ord) |
blog_tags_mui | Tag translations (name, slug, description, meta fields) |
blog_blog_tags | Article-to-tag lookup (blog_id, blog_tag_id, unique) |
blog_author | Author master (banner_image, ord) |
blog_author_mui | Author translations (name, slug, description, meta fields) |
Client Extension Points
indexExtras(),blogArticleExtras(),blogCategoryExtras()hooks: Add custom data to respective pagesblogArticleEvents()hook: Custom analytics/tracking events on article viewremapActions()hook:protected function remapActions(): arraylists the actions_remap()may call from the URL. A public action a fork adds toBlog.phpis not routable until it is added, e.g.return array_merge(parent::remapActions(), ['feed']);. A fork that overrides_remap()with its ownmethod_exists()dispatch must port the allow-listisArticleVisible()/isScheduledArticle(): the article page's visibility rule (published and not scheduled, or a back-office session). A fork that overridesblogArticle()should gate onisArticleVisible()rather than copy the rule; overrideisScheduledArticle()to change the cutoff, e.g. to match a fork's own listing window- Comment moderation: Extend admin workflow;
manageBlogComments()is overridable - Product relations:
blog_producttable with priority ordering - RSS feed: Available via
rss()method; customize title/description via Registry - Search: Solr v1/v2 integration via
search_modelorsearch_model_v2 - Content embeddings: Product/product-list shortcodes in article body
- Builder blocks:
blogArticleposition for page builder content - Views:
{client_views}/blog/-- index, article, category, tag, author, search, rss templates
Known Issues & Security Gaps
An article with no category answered HTTP 500 on the standard storefront.— Fixed (#900, pull request #350).blogRelativeArticles()andgetPreviousNext()passed the article's category ids towhere_in()without checking for an empty list. This repo's CodeIgniter query builder throwsInvalidArgumentExceptionon an empty array (system/database/DB_query_builder.php:751-753) and nothing on the request path caught it, soblogArticle()→blogArticleExtras()ended in the exception handler's 500 (application/helpers/log_helper.php:370-377). Both methods now return early on an empty list (see "Articles with no category" under Step 3), pinned bytests/Legacy/Blog/AdvBlogModelEmptyCategoryGuardTest.php. The articles that hit it were the category-less onesCms\Blog\Article\WriteService::create()produces (see IN-24 MCP Connector, Known Issue 18).The related-articles list ignored publish state and date.— Fixed (#901, pull request #351).blogRelativeArticles()filtered only on a shared category, ablog_idother than the current article's, andlang. Its caller passed no publish or date condition (ecommercen/blog/controllers/Adv_blog.php:323-331), unlikegetPreviousNext(), which it restricts tois_published = trueandblog_date <= today(:337). A template that rendersarticleRelativescould therefore list drafts and future-dated articles. The main template'sapplication/views/main/layouts/blog/blog_post.phpdoes not render the list; a client template can. The method now applies the same restriction itself, asblog.is_published = trueandblog.blog_date <= date('Y-m-d')(ecommercen/blog/models/Adv_blog_model.php:492-493), so every caller gets it with no signature change. Like the storefront's other listings, the list also leaves out articles whoseblog_dateisNULL. Pinned bytests/Legacy/Blog/AdvBlogModelArticleNeighboursVisibilityTest.php.An article missing from its own previous/next list got a wrong "next" link.— Fixed (#901, pull request #351).getPreviousNext()looks for the current article in the list its caller restricts to published, already-dated articles (ecommercen/blog/controllers/Adv_blog.php:337). Two kinds of article page are not in that list. One is a draft, whichblogArticle()serves when the session carries the back-officeloggedInflag (Adv_blog.php:243-246; the flag is set by the admin login,application/libraries/Advauth.php:128, 148, and by SSO,ecommercen/sso/controllers/AdvSso.php:76). The other is a published article dated after the start of today (one published today at 16:00 stays out of the list until midnight).blogArticle()serves it to everyone once itsblog_datehas passed, and before that only to a back-office session, as for a draft (isArticleVisible(),Adv_blog.php:243-246). Not finding the article, the method left$articlePositionatnull, sopreviouswas null andnextwas$articles[1]— the second-newest article in its categories, unrelated to this one. It now returns['previous' => null, 'next' => null]when the article is not in the list (ecommercen/blog/models/Adv_blog_model.php:209-215). Pinned by the same test.Future-dated articles are listed in the product article blocks before their date. The article page was fixed by #902 (pull request #352).
blogArticle()used to refuse an unpublished article but never compareblog_datewith the current date, andblog_model::getBlogData()(ecommercen/blog/models/Adv_blog_model.php:505-517) has no date condition either, so a published article dated in the future was served to anyone who had its URL. It now answers 404 to a visitor until thatblog_datehas passed; only a back-office session can open it earlier (isArticleVisible(),ecommercen/blog/controllers/Adv_blog.php:243-246). The product-page and product-category article blocks still list it, because they filter onis_publishedonly (ecommercen/eshop/controllers/Adv_products.php:1163-1173,ecommercen/eshop/controllers/Adv_product_categories.php:1440-1450), and their links now lead to that 404. The blocks are shown whenESHOP.BLOG_PRODUCT_ENABLEDorESHOP.BLOG_PRODUCT_CATEGORY_ENABLEDis on.Listings hide an article for the rest of its publish day (
Adv_blog.php:121, 337, 393, 505-509, 610, 713;Adv_blog_model.php:492-493): the listing window isblog_date <= date('Y-m-d').blog_dateis aDATETIMEand the admin picker sets a time of day (application/views/admin/footer_js.php:308-312), while MySQL compares the bare date as00:00:00. An article dated today at 14:30 therefore stays off every listing until the next day. Search compares againstdate('Y-m-d H:i:s')(ecommercen/search/models/Adv_search_model.php:715, 746,Adv_search_model_v2.php:1004, 1035), so it lists the article from 14:30, the moment its article page opens (item 4).NULL-dated articles are never listed (
database/migrations/20241024093212_change_blog_date_to_datetime.php):blog_dateisDATETIME NULL DEFAULT NULL, andNULL <= '…'is never true, so an article with no date appears in no listing, RSS feed or search result. The admin form always writes a date (ecommercen/blog/controllers/Adv_blog_admin.php:334), butPOST /rest/cms/blog/articledoes not require one (src/Domains/Cms/Blog/Article/WriteData.php:51). The article page is still served, and it shows the date as01-01-1970, becausedate("d-m-Y", strtotime(null))formats the Unix epoch (Adv_blog.php:277).REST visibility applies
is_publishedonly (src/Domains/Cms/Blog/Article/ArticleVisibilityScope.php:46-52): storefront (non-backend) REST reads of articles, directly or through a relation, hide drafts but not future-dated articles. A headless storefront therefore shows articles the legacy listings hide. The docblock records this as deliberate:FilterRequestTypehas no<=operator, and a naive window would drop NULL-dated articles (item 6).
Related Flows
- CF-02 Product Detail -- articles shown on PDP (blog-product two-way sync)
- CF-04 Search -- blog articles appear in search results (Solr v2)
- CF-35 Page Builder --
blogArticlebuilder block position replaces article content - AD-12 Blog Management -- admin CRUD for articles, categories, tags, authors, comments
- IN-24 MCP Connector --
create_articlecreates articles with no category or tag