Skip to content

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:

  • /blog or /blog/all main 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/rss RSS 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 = true AND blog_date <= date('Y-m-d') (Adv_blog.php:121, 337, 393, 505-509, 610, 713; related articles: Adv_blog_model.php:492-493). Because blog_date is a DATETIME, today's date compares as today at 00:00:00 (Known Issue 5). Blog search uses blog_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 whose blog_date is still in the future (scheduled) until that moment (Adv_blog::isArticleVisible() / isScheduledArticle(), Adv_blog.php:243-246). It compares blog_date with 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). A NULL blog_date is not a schedule: the page opens, though no listing shows it (Known Issue 6). Only a session carrying the back-office login flag loggedIn opens 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 sets customer_logged_in instead (ecommercen/eshop/models/Adv_customer_model.php:342), so logged-in customers get the 404 too. The REST read path applies is_published only, 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_COMMENTS registry
  • Blog-product two-way sync configurable (BLOG_PRODUCT_TWO_WAY_SYNC)
  • Builder block integration for rich article content via blogArticle position
  • 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 ​

MethodPathAuthDescription
GET/rest/cms/blog/articleGuestList articles (filterable, sortable, paginated)
GET/rest/cms/blog/article/{id}GuestGet article by ID
POST/rest/cms/blog/articleBackend (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/authorGuestList authors
POST/rest/cms/blog/authorBackend (CMS)Create/update author
DELETE/rest/cms/blog/author/{id}Backend (CMS)Delete author
GET/rest/cms/blog/categoryGuestList categories
POST/rest/cms/blog/categoryBackend (CMS)Create/update category
DELETE/rest/cms/blog/category/{id}Backend (CMS)Delete category
GET/rest/cms/blog/tagGuestList tags
POST/rest/cms/blog/tagBackend (CMS)Create/update tag
DELETE/rest/cms/blog/tag/{id}Backend (CMS)Delete tag
GET/rest/cms/blog/commentGuest (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/commentBackend (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 ​

URLMethodDescription
/blog or /blog/allindex()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/rssrss()RSS XML feed

Code Flow ​

Step 1: URL Routing via _remap() ​

File: ecommercen/blog/controllers/Adv_blog.php

  1. all: Routes to index()
  2. Allow-listed action: _remap() calls a method only when the decoded segment matches an entry of remapActions()
    • Default list: index, blogAuthor, rss, search
    • blogAuthor is how the author page is reached: /blog/blogAuthor/{author-slug}, the URL ecommercen/helpers/theme_helper.php:644 builds
    • 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() and searchPage() and inherited methods, falls through to the slug lookups below, then 404
  3. Category slug match: blog_category_model->getCategoryBySlug() (cached) -> blogCategory()
  4. Tag slug match: blog_tags_model->getTagBySlug() (cached) -> blogTag()
  5. Article slug match: blog_model->getArticleBySlug() (cached) -> blogArticle()
  6. Fallback: 404

Step 2: Article Index ​

File: ecommercen/blog/controllers/Adv_blog.php::index()

  1. Pagination: Page number from URL, offset calculated as (page - 1) * 9
  2. Query: blog_model->getBlogsList() with is_published=true, blog_date<=date('Y-m-d')
  3. Featured article: First article on page 1 is shifted to mainArticle
  4. Sidebar: Categories via getCategoriesFront(), tags via getTagsFront()
  5. Hreflang: Language switcher URLs via lang_uri
  6. Hook: indexExtras() -- empty by default
  7. Tag rendering: getBlogListingRelatedTags() for sidebar tags
  8. Render: blogIndex layout

Step 3: Single Article Page ​

File: ecommercen/blog/controllers/Adv_blog.php::blogArticle()

  1. Fetch: blog_model->getBlogData($slug, $lang) -- 404 if not found; 404 if unpublished or scheduled, unless the session carries the back-office loggedIn flag (isArticleVisible())
  2. SEO: Meta tags from article MUI fields
  3. Hreflang: MUI slug lookup per language
  4. Content embeddings: renderBlogContentEmbeddings() -- extracts product/product-list embeds from article description
  5. Products: renderBlogProducts() -- fetches linked products from blog_product table (sorted by priority)
  6. Builder block: blockBuilder->frontRender() for blogArticle position using builder_block_id
  7. 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) to is_published = true and blog_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)
  8. Author data: blog_author_model->getAuthorRecord() plus categories
  9. 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 to is_published = true and blog_date <= today (Adv_blog_model.php:158-222, conditions at ecommercen/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)
  10. Slider: Optional slider if slider_id set
  11. Hook: blogArticleExtras() -- loads author, categories, related articles, prev/next and slider by default (items 7-10; categories, related articles and prev/next are cached through pscache)
  12. Events: blogArticleEvents() -- empty hook for client
  13. Comments: manageBlogComments($blogId)
  14. 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()

  1. Feature gate: OTHER.ENABLE_BLOG_COMMENTS registry setting
  2. POST handling: On form submit, validates comment, blog_commenter_email, blog_commenter_name
  3. Save: blog_comments_model->saveComment() -- status defaults to pending
  4. Flash: Success message, redirect to same page
  5. Display: getBlogComments($blogId, 10) -- only shows approved comments, ordered by entry_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 method batchUpdateStatus() (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)

File: ecommercen/blog/controllers/Adv_blog.php::search()

  1. Guard: Empty search term returns 410 Gone
  2. AJAX path: liveSearch($term) (protected, called by search(), not URL-routable) -- returns JSON results for autocomplete
  3. Page path: searchPage($term, $pageNumber) (protected, called by search(), not URL-routable) -- full rendered search results page
  4. Solr integration: Routes to search_model (v1) or search_model_v2 (v2) based on solrSearch.version config
  5. Results: Paginated articles matching search term, with sidebar categories/tags

Step 6: RSS Feed ​

File: ecommercen/blog/controllers/Adv_blog.php::rss()

  1. Config: Title and description from Registry BLOG.RSSTITLE / BLOG.RSSDESCRIPTION (per language)
  2. Articles: All published articles via getBlogsList()
  3. Output: XML content type, rendered via blog/rss view template

Domain Layer ​

ComponentPath
Article Servicesrc/Domains/Cms/Blog/Article/Service.php
Article WriteServicesrc/Domains/Cms/Blog/Article/WriteService.php
Article Entitysrc/Domains/Cms/Blog/Article/Repository/Entity.php
REST Controllerssrc/Rest/Cms/Controllers/BlogArticle.php, BlogCategory.php, BlogTag.php, BlogAuthor.php, BlogComment.php
Legacy Controllerecommercen/blog/controllers/Adv_blog.php
Blog Modelecommercen/blog/models/Adv_blog_model.php (not shown -- main article queries)
Comments Modelecommercen/blog/models/Adv_blog_comments_model.php
Product Link Modelecommercen/blog/models/Adv_blog_product_model.php
Author Modelecommercen/blog/models/Adv_blog_author_model.php
Category Modelecommercen/blog/models/Adv_blog_category_model.php
Tags Modelecommercen/blog/models/Adv_blog_tags_model.php
Admin ControllersAdv_blog_admin.php, Adv_blog_comments_admin.php, Adv_blog_tags_admin.php

Data Model ​

blog ​

ColumnTypeDescription
idint (PK, AI)Article ID
blog_author_idint (FK)Author reference
banner_imagevarchar(250)Banner image path
blog_datedatetime (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_publishedtinyint(1)Whether article is published
is_promotinyint(1)Promotional flag
youtube_video_idvarchar(250)Embedded YouTube video
spotify_podcast_idvarchar(250)Embedded Spotify podcast
hitsintView counter

blog_mui ​

ColumnTypeDescription
idint (PK, AI)MUI entry ID
blog_idint (FK)Parent article
slugvarchar(250)URL slug
titlevarchar(255)Article title
meta_keywordstextSEO keywords
meta_descriptiontextSEO description
meta_titletextSEO title
descriptionlongtextFull article content (supports content embeddings)
small_descriptiontextExcerpt/summary
langvarchar(2)Language code

blog_comments ​

ColumnTypeDescription
idint (PK, AI)Comment ID
blog_idint (FK)Parent article
emailvarchar(255)Commenter email
namevarchar(255)Commenter name
comment_contenttextComment text
entry_datedatetimeSubmission timestamp (defaults to current_timestamp())
parent_comment_idint (nullable)For threaded replies
statusenumapproved, pending, rejected (default: pending)
langvarchar(4)Language code

blog_product ​

ColumnTypeDescription
blog_idint (PK, FK)Article reference
product_idint (PK, FK)Product reference
priorityintDisplay order (0 = default)

Supporting Tables ​

TablePurpose
blog_categoriesCategory master (banner_image, is_active, ord, parent_id)
blog_categories_muiCategory translations (title, slug, description, meta fields)
blog_blog_categoriesArticle-to-category lookup (blog_id, blog_category_id)
blog_tagsTag master (is_active, ord)
blog_tags_muiTag translations (name, slug, description, meta fields)
blog_blog_tagsArticle-to-tag lookup (blog_id, blog_tag_id, unique)
blog_authorAuthor master (banner_image, ord)
blog_author_muiAuthor translations (name, slug, description, meta fields)

Client Extension Points ​

  • indexExtras(), blogArticleExtras(), blogCategoryExtras() hooks: Add custom data to respective pages
  • blogArticleEvents() hook: Custom analytics/tracking events on article view
  • remapActions() hook: protected function remapActions(): array lists the actions _remap() may call from the URL. A public action a fork adds to Blog.php is not routable until it is added, e.g. return array_merge(parent::remapActions(), ['feed']);. A fork that overrides _remap() with its own method_exists() dispatch must port the allow-list
  • isArticleVisible() / isScheduledArticle(): the article page's visibility rule (published and not scheduled, or a back-office session). A fork that overrides blogArticle() should gate on isArticleVisible() rather than copy the rule; override isScheduledArticle() 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_product table with priority ordering
  • RSS feed: Available via rss() method; customize title/description via Registry
  • Search: Solr v1/v2 integration via search_model or search_model_v2
  • Content embeddings: Product/product-list shortcodes in article body
  • Builder blocks: blogArticle position for page builder content
  • Views: {client_views}/blog/ -- index, article, category, tag, author, search, rss templates

Known Issues & Security Gaps ​

  1. An article with no category answered HTTP 500 on the standard storefront. — Fixed (#900, pull request #350). blogRelativeArticles() and getPreviousNext() passed the article's category ids to where_in() without checking for an empty list. This repo's CodeIgniter query builder throws InvalidArgumentException on an empty array (system/database/DB_query_builder.php:751-753) and nothing on the request path caught it, so blogArticle() → 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 by tests/Legacy/Blog/AdvBlogModelEmptyCategoryGuardTest.php. The articles that hit it were the category-less ones Cms\Blog\Article\WriteService::create() produces (see IN-24 MCP Connector, Known Issue 18).

  2. The related-articles list ignored publish state and date. — Fixed (#901, pull request #351). blogRelativeArticles() filtered only on a shared category, a blog_id other than the current article's, and lang. Its caller passed no publish or date condition (ecommercen/blog/controllers/Adv_blog.php:323-331), unlike getPreviousNext(), which it restricts to is_published = true and blog_date <= today (:337). A template that renders articleRelatives could therefore list drafts and future-dated articles. The main template's application/views/main/layouts/blog/blog_post.php does not render the list; a client template can. The method now applies the same restriction itself, as blog.is_published = true and blog.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 whose blog_date is NULL. Pinned by tests/Legacy/Blog/AdvBlogModelArticleNeighboursVisibilityTest.php.

  3. 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, which blogArticle() serves when the session carries the back-office loggedIn flag (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 its blog_date has 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 $articlePosition at null, so previous was null and next was $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.

  4. 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 compare blog_date with the current date, and blog_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 that blog_date has 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 on is_published only (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 when ESHOP.BLOG_PRODUCT_ENABLED or ESHOP.BLOG_PRODUCT_CATEGORY_ENABLED is on.

  5. 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 is blog_date <= date('Y-m-d'). blog_date is a DATETIME and the admin picker sets a time of day (application/views/admin/footer_js.php:308-312), while MySQL compares the bare date as 00:00:00. An article dated today at 14:30 therefore stays off every listing until the next day. Search compares against date('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).

  6. NULL-dated articles are never listed (database/migrations/20241024093212_change_blog_date_to_datetime.php): blog_date is DATETIME NULL DEFAULT NULL, and NULL <= '…' 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), but POST /rest/cms/blog/article does not require one (src/Domains/Cms/Blog/Article/WriteData.php:51). The article page is still served, and it shows the date as 01-01-1970, because date("d-m-Y", strtotime(null)) formats the Unix epoch (Adv_blog.php:277).

  7. REST visibility applies is_published only (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: FilterRequestType has no <= operator, and a naive window would drop NULL-dated articles (item 6).