Ultimate · Let's Talk (Jz52_shuoshuo) Plugin Template Creation Tutorial

This document is intended for Z‑Blog theme developers. It explains how to create a moments‑page template (lm‑shuoshuo.php) for the Ultimate Moments plugin, so that the moments page matches your theme’s visual style.
The plugin ships with a complete built‑in template: zb_users/plugin/Jz52_shuoshuo/template/shuoshuo.php, together with its supporting css/front.css and js/front.js. Theme developers may copy‑modify these files or build a custom template from scratch following this guide.
1. How Templates Take Effect
| Priority | Template File | Description |
|---|---|---|
| 1 (Highest) | zb_users/theme/{current‑theme}/template/lm‑shuoshuo.php | Theme‑provided moments‑page template, fully controlled by the theme author |
| 2 (Fallback) | zb_users/plugin/Jz52_shuoshuo/template/shuoshuo.php | Plugin built‑in fallback template |
Workflow: If lm‑shuoshuo.php exists inside your active theme’s template/ folder, the frontend moments list page (/moments/) and moments detail page (/moment/{ID}.html) will automatically use this theme template. Delete the file to revert to the plugin’s built‑in template.
Activation Options (choose one):
After placing or editing the template file, simply visit the frontend moments page. The system will detect template changes and recompile automatically.
Or go to the Z‑Blog backend dashboard and click Clear Cache & Recompile Templates to force a refresh.
Template compiled cache: Compiled theme templates are stored at
zb_users/cache/compiled/{theme‑id}/lm‑shuoshuo.phpand maintained automatically by Z‑Blog.
Comment Section Partial Templates (Detail‑page comment area can also be fully customized)
The comment section (comment list, single‑comment item, and comment form) is split into three partial templates. They follow the same override rules as lm‑shuoshuo.php:
| Partial File | Purpose |
|---|---|
lm‑shuoshuo‑comments.php | Main comment‑section template: includes title with comment count, comment‑item loop, empty‑state prompt, and form / closed‑comments notice |
lm‑shuoshuo‑comment.php | Single‑comment item: avatar, username, content, floor number, reply button; supports recursive nested replies |
lm‑shuoshuo‑commentpost.php | Comment submission form: hidden fields for logged‑in users; visitor nickname‑email‑website inputs, content textarea, submit button |
Override method: Place the file(s) with identical names under your active theme’s template/ directory, for example template/lm‑shuoshuo‑comment.php. You only need to override files you want to modify. If you only replace lm‑shuoshuo‑comment.php, the comment‑section header and submission form will keep using plugin defaults.
Fallback mechanism: If your theme only supplies
lm‑shuoshuo.phpwithout any partial template files, the plugin will automatically fall back to its built‑in partial templates without throwing errors. This is implemented via theFilter_Plugin_Template_GetTemplatehook.
2. Template Engine Syntax Quick Reference
lm‑shuoshuo.php uses Z‑Blog’s standard template engine, identical to index.php and single.php inside themes.
| Syntax | Description | Example |
|---|---|---|
{$variable} | Output variable value (raw echo, no automatic HTML escaping) | {$jz52_type} |
{$variable.property} | Dot notation translates to object property access | {$jz52_moment.Url} → $jz52_moment‑>Url |
{php} … {/php} | Raw PHP code block | {php}echo date('Y');{/php} |
{if condition} … {elseif condition} … {else} … {/if} | Conditional branch (conditions cannot span multiple lines) | {if $jz52_type == 'list'}List{else}Detail{/if} |
{foreach $array as $item} … {/foreach} | Loop iteration | {foreach $jz52_moments as $jz52_moment} … {/foreach} |
{foreach $array as $key => $value} … {/foreach} | Loop with key‑value pairs | See tag‑navigation example |
{for expression} … {/for} | Numeric for‑loop | {for $i=1; $i<3; $i++} |
{switch …} | Switch‑case branch | Rarely used |
{function(parameter)} | Output return value from a function | {Jz52_shuoshuo_ListUrl(1, $jz52_t)} |
{template:partial‑name} | Include partial template | {template:pagebar} |
{* comment *} | Template‑only comment | {* This is a comment *} |
Two critical notes:
{$variable}does NOT automatically escape HTML. When outputting plain‑text fields such as titles, usernames or tag names, use:
{php}echo htmlspecialchars($variable, ENT_QUOTES, 'UTF‑8');{/php}.
For pre‑rendered HTML output provided by the plugin (Html / MediaHtml properties), output directly with {$variable}.
Dots in
{$variable.property}translate to‑>object operators.{$jz52_moment.TagList}accesses the object property / methodTagList.
3. Template Variable Contract
All template variables injected by this plugin use the jz52_ prefix to prevent naming collisions with core Z‑Blog or other plugins. During rendering these variables become global scope. Generic names such as $type, $tags, $page must be avoided.
Global Variables (Available on both list and detail pages)
| Variable | Type | Description |
|---|---|---|
$jz52_type | string | Page type: 'list' (moments listing), 'single' (single moment detail) |
$jz52_cfg | object | Plugin configuration object ($zbp‑>Config('Jz52_shuoshuo')). See below for common keys. |
$jz52_isroot | bool | Whether current visitor is an administrator |
$jz52_can_post | bool | Whether visitor can publish moments from frontend (controlled by backend setting "Allow Frontend Publishing" plus minimum user‑group permission). Use this in list templates to conditionally render the composer box. |
$jz52_can_upload | bool | Whether visitor may upload images inside the composer box (separately controlled by backend permission setting). Use this to show / hide image upload button. |
$jz52_posturl | string | Frontend publish API endpoint URL (POST fields: content + csrfToken + media) |
$jz52_uploadurl | string | Frontend image upload API endpoint URL (POST fields: file + csrfToken) |
$jz52_pluginurl | string | Plugin directory URL e.g. http://your‑domain/zb_users/plugin/Jz52_shuoshuo/; used to load plugin CSS / JavaScript assets |
$jz52_likeurl | string | Like‑submit API endpoint URL (POST request) |
$jz52_rssurl | string | RSS feed URL |
$jz52_listurl | string | Base URL for moments listing homepage |
$jz52_allurl | string | URL for "All‑tags" filter, equivalent to page‑1 listing without tag filtering |
$jz52_title | string | Complete HTML <title> page title |
$jz52_pageTitle | string | Main page heading; equals section name for list page, moment title or excerpt for detail page |
List‑Page‑Only Variables
| Variable | Type | Description |
|---|---|---|
$jz52_page | int | Current page number (starts from 1) |
$jz52_totalPages | int | Total page count |
$jz52_tag | string | Currently‑filtered tag name; empty string when no tag filter is active |
$jz52_tags | array | Tag statistics array format: tag‑name => post‑count; used to render tag navigation |
$jz52_moments | array | Array of moment objects for current page (Jz52_shuoshuo[]). See Chapter 4 for object properties. |
$jz52_pager | string | Pre‑rendered pagination HTML string; empty string '' if only one page exists. Check with condition {if $jz52_pager != ''}. |
Detail‑Page‑Only Variables
| Variable | Type | Description |
|---|---|---|
$jz52_moment | object | Target single‑moment object (Jz52_shuoshuo). Properties described in Chapter 4. |
Detail‑Page Comment‑Section Variables (only present on detail view)
| Variable | Type | Description |
|---|---|---|
$jz52_show_comments | bool | Always true on detail page; not injected for listing pages. Use to conditionally render comment section. |
$jz52_comments | array | Top‑level root‑level comment object array (Jz52_shuoshuo_Comment[]). Nested child replies are pre‑attached under property Comments. |
$jz52_comment_count | int | Total number of approved comments |
$jz52_comment_enabled | bool | Master switch for comment functionality (backend config key comment_enable) |
$jz52_cmt_posturl | string | Comment submit API endpoint URL (cmd.php?act=jz52_shuoshuo_comment_post) |
$jz52_cmt_logged_in | bool | Whether visitor is currently logged‑in |
$jz52_cmt_user_name / $jz52_cmt_user_email / $jz52_cmt_user_home | string | Logged‑in user’s name / email / homepage URL; empty for guests, used for form prefill |
Comment‑section rendering convention: In detail‑page templates render comment section using exactly:
{if $jz52_show_comments}{template:lm‑shuoshuo‑comments}{/if}. Recursive nested replies and form rendering are handled internally by partial templates. Your theme only needs to ensure variable$jz52_commentsis available.
Core System Variables (no jz52_ prefix, do not add prefix)
| Variable | Description |
|---|---|
$zbp | Global Z‑Blog core object. Common uses: {$zbp.name} (site name), {$zbp.host} (site base URL). |
$lang | Language pack object; retrieve plugin locale strings with {$lang['Jz52_shuoshuo']['key‑name']} (see Chapter 8). |
Plugin‑Config Keys ($jz52_cfg‑>key‑name)
| Key | Type | Default | Description |
|---|---|---|---|
title | string | Moments | Section display name |
pagesize | int | 10 | Items shown per page |
like_enable | int | 1 | Toggle like feature (1 = on, 0 = off) |
rss_enable | int | 1 | Toggle RSS feed (1 = on, 0 = off) |
show_author | int | 1 | Toggle frontend author‑name display (1 = on, 0 = off) |
post_enable | int | 1 | Toggle frontend composer box visibility; effective together with permission check $jz52_can_post |
Frontend Composer Box (List Page)
When $jz52_can_post evaluates true on list pages, render a composer UI similar to the reference implementation in plugin template/shuoshuo.php with CSS class .jz52‑shuoshuo‑composer. Permissions are governed by backend setting "Minimum User‑Group for Frontend Publishing". If set to guest level, unauthenticated visitors can submit content (submissions go into moderation queue, author name shown as Guest).
Interaction specifications:
‑ Collapse / expand only adjusts textarea height. Default state adds CSS class is‑collapsed. On focus apply is‑expanded for taller input area. Toolbar buttons (image / emoji), character counter and submit button stay permanently visible.
‑ Show image upload button only if $jz52_can_upload is true. It triggers hidden <input type="file">. Selected files are uploaded one‑by‑one via $jz52_uploadurl using FormData POST with file and csrfToken. Successful response format {code:0,data:{url}}. Uploaded images are stored under zb_users/upload/jz52_shuoshuo/YYYYMM/ managed by plugin (images are not added to Z‑Blog core attachment table). Maximum four images per post.
‑ Emoji button opens panel .jz52‑shuoshuo‑composer‑emoji with grid .jz52‑ss‑emoji‑grid. Clicking emoji inserts character at text‑cursor position.
‑ Submit moment content to $jz52_posturl by POST request: parameters content, csrfToken, media (JSON‑encoded array of uploaded image URLs). Success response format: {code:0,msg}. Administrators receive success message, non‑administrators receive "submitted for moderation". Page refreshes after publish. Themes can override CSS classes: .jz52‑shuoshuo‑composer*, .jz52‑ss‑tool‑btn, .jz52‑ss‑preview‑*, .jz52‑ss‑emoji‑*.
4. Moment Object ($jz52_moment / List‑Item) Properties
Raw Data Fields (direct access)
| Property | Type | Description |
|---|---|---|
ID | int | Unique moment entry ID |
AuthorID | int | Publishing user ID |
Title | string | Moment title (can be empty string) |
Content | string | Raw plain‑text content |
Html | string | Pre‑rendered moment HTML. Line‑breaks converted to <br>. Output directly with {$jz52_moment.Html}, do not escape. |
Media | string | Media metadata stored as JSON string |
Tags | string | Raw tag string in format ,tag1,tag2,. Usually use property TagList instead. |
Visible | string | Visibility setting: public / private |
Approved | bool | Moderation approval status |
IsTop | int | Pin‑to‑top flag (1 = pinned) |
LikeNums | int | Like count number |
ViewNums | int | View count number |
PostTime | int | Unix timestamp of publish time; use TimeText for human‑readable formatted output |
CreateTime / UpdateTime | int | Unix timestamps for record creation / last modification |
Computed Read‑Only Properties (usable directly in templates)
| Property | Type | Description |
|---|---|---|
Url | string | URL to moment detail page |
Author | object | Z‑Blog Member object for author; empty dummy member for guests, check validity with ID <= 0 |
AuthorName | string | Display‑ready author name (nickname or username) |
AuthorFirstChar | string | First character of author’s display name; used for text‑based fallback avatar |
Avatar | string | Avatar image URL; empty string for guest / missing avatar |
TagList | array | Normalized tag‑name array e.g. array('test','moments') |
MediaHtml | string | Pre‑rendered HTML markup for attached media (images, video, audio). Empty string if no attachments. Output directly. |
TimeText | string | Human‑readable localized timestamp adjusted for site timezone |
SubContent | string | Short excerpt limited to first 30 characters of content |
IsLiked | bool | Whether current visitor has liked this entry (tracked via browser Cookie) |
IsPrivate | bool | Convenience flag equivalent to Visible == 'private' |
IsPending | bool | Convenience flag equivalent to unapproved status Approved != true |
Visibility note: Private and pending‑moderation moments are filtered by plugin backend logic and are visible only to administrators on frontend. Theme templates do not need to implement access filtering logic. You may add status badge indicators wrapped with
{if $jz52_isroot}for admin‑only hints.
Comment Object ($jz52_cmt — only available inside comment partial templates)
Inside lm‑shuoshuo‑comment.php partial template, loop variable is $jz52_cmt of type Jz52_shuoshuo_Comment:
| Property | Type | Description |
|---|---|---|
ID | int | Unique comment ID |
Name | string | Commenter display‑name; input sanitized on save, still recommend htmlspecialchars before HTML output |
HomePage | string | Commenter website URL; sanitized on database save, only valid http(s) links are preserved |
Content | string | Raw unescaped comment text |
PostTime | int | Unix timestamp for comment submission |
IsChecking | int | Moderation pending flag (1 = pending review) |
Author | object | Z‑Blog Member object for logged‑in comment authors; empty dummy member for guests (ID <= 0, Avatar empty) |
AvatarText | string | First‑character text for fallback text avatar |
HomeLink | string | Sanitized valid http(s) homepage URL; empty string for invalid / missing values; use to conditionally render anchor <a> tag |
ContentHtml | string | Fully‑processed safe HTML for comment content (HTML escaping, auto‑link conversion, newline handling). Output directly: {$jz52_cmt.ContentHtml}. |
IsCheckingBadge | string | Pre‑rendered HTML badge "Pending Review", visible only for admin users; empty string for guests, output directly |
TimeText | string | Human‑readable formatted comment timestamp |
Comments | array | Nested child‑reply comment array for threaded replies |
Level | int | Comment nesting depth value (0 for top‑level root comment) |
Floor‑number convention: Root‑level comments receive floor‑number variable $jz52_cmt_floor injected from lm‑shuoshuo‑comments.php loop counter (starts from 1). Inside single‑comment partial template show floor badge only if condition {if $jz52_cmt_floor > 0} evaluates true. Before recursive rendering of nested replies, $jz52_cmt_floor will be reset to 0 so child replies do NOT display floor numbers.
5. Plugin Functions Available (call within {php} blocks)
| Function | Description |
|---|---|
Jz52_shuoshuo_ListUrl($page, $tag = '') | Build moments‑listing URL with target page number and optional tag filter. Example: Jz52_shuoshuo_ListUrl(1, 'test') |
Jz52_shuoshuo_SingleUrl($id) | Build URL for single‑moment detail view. Normally you would use $jz52_moment.Url instead. |
Jz52_shuoshuo_RssUrl() | Return RSS‑feed URL string. Normally use variable $jz52_rssurl. |
6. Full Example Template
This complete working sample can be saved as zb_users/theme/{your‑theme}/template/lm‑shuoshuo.php. The same template file handles both listing and detail views; branch logic uses $jz52_type. You may alternatively copy plugin’s built‑in template/shuoshuo.php and modify styles.
{php}
if (!defined('ZBP_PATH')) {
exit('Access denied');
}
{/php}
{* Template Name:说说模板 *}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{php}echo htmlspecialchars($jz52_title, ENT_QUOTES, 'UTF-8');{/php}</title>
<link rel="alternate" type="application/rss+xml" title="{php}echo htmlspecialchars($jz52_pageTitle, ENT_QUOTES, 'UTF-8');{/php}" href="{$jz52_rssurl}" />
{* 建议复用插件自带样式,或换成你自己的主题样式 *}
<link rel="stylesheet" type="text/css" href="{$jz52_pluginurl}css/front.css" />
</head>
<body>
{* ============ 列表页 ============ *}
{if} $jz52_type == 'list' {
<h1>{php}echo htmlspecialchars($jz52_pageTitle, ENT_QUOTES, 'UTF-8');{/php}</h1>
{* 标签导航:$jz52_tags 是 标签名=>数量 的关联数组 *}
{if} count($jz52_tags) > 0 {
<nav>
<a class="{if $jz52_tag == ''}is-active{/if}" href="{$jz52_allurl}">{$lang['Jz52_shuoshuo']['all']}</a>
{foreach} $jz52_tags as $jz52_tname => $jz52_tcount {
<a class="{if $jz52_tag == $jz52_tname}is-active{/if}"
href="{php}echo htmlspecialchars(Jz52_shuoshuo_ListUrl(1, $jz52_tname), ENT_QUOTES, 'UTF-8');{/php}">
{php}echo htmlspecialchars($jz52_tname, ENT_QUOTES, 'UTF-8');{/php} ({$jz52_tcount})
</a>
{/foreach}
</nav>
{/if}
{if} count($jz52_moments) == 0 {
<p>{$lang['Jz52_shuoshuo']['no_moments']}</p>
{else}
<ul>
{foreach} $jz52_moments as $jz52_moment {
<li>
<article>
{* 头部:作者 + 时间 + 管理员徽标 *}
<header>
{if} $jz52_cfg->show_author == 1 {
<span>
{if} $jz52_moment->Avatar != '' {
<img src="{php}echo htmlspecialchars($jz52_moment->Avatar, ENT_QUOTES, 'UTF-8');{/php}" alt="" loading="lazy" />
{else}
<span class="jz52-shuoshuo-avatar jz52-shuoshuo-avatar-text">{php}echo htmlspecialchars($jz52_moment->AuthorFirstChar, ENT_QUOTES, 'UTF-8');{/php}</span>
{/if}
<b>{php}echo htmlspecialchars($jz52_moment->AuthorName, ENT_QUOTES, 'UTF-8');{/php}</b>
</span>
{/if}
<a href="{$jz52_moment.Url}">
<time datetime="{$jz52_moment.TimeText}">{php}echo htmlspecialchars($jz52_moment->TimeText, ENT_QUOTES, 'UTF-8');{/php}</time>
</a>
{if} $jz52_isroot {
{if} $jz52_moment->IsPrivate <span>{$lang['Jz52_shuoshuo']['visible_private']}</span>{/if}
{if} $jz52_moment->IsPending <span>{$lang['Jz52_shuoshuo']['pending']}</span>{/if}
{/if}
</header>
{* 正文 HTML(已渲染,直接输出)与媒体 *}
<div>{$jz52_moment.Html}</div>
{if} $jz52_moment->MediaHtml != ''{{$jz52_moment.MediaHtml}{/if}
{* 底部:标签 + 点赞 *}
<footer>
{if} count($jz52_moment->TagList) > 0 {
<span>
{foreach} $jz52_moment->TagList as $jz52_t {
<a href="{php}echo htmlspecialchars(Jz52_shuoshuo_ListUrl(1, $jz52_t), ENT_QUOTES, 'UTF-8');{/php}">#{php}echo htmlspecialchars($jz52_t, ENT_QUOTES, 'UTF-8');{/php}</a>
{/foreach}
</span>
{/if}
{if} $jz52_cfg->like_enable == 1 {
<button type="button" class="jz52-shuoshuo-like{if $jz52_moment.IsLiked} is-liked{/if}" data-id="{$jz52_moment.ID}">
<span>{$jz52_moment.LikeNums}</span> {$lang['Jz52_shuoshuo']['like']}
</button>
{/if}
</footer>
</article>
</li>
{/foreach}
</ul>
{if} $jz52_pager != ''{{$jz52_pager}{/if}
{/if}
{* ============ 详情页 ============ *}
{else}
<article class="jz52-shuoshuo-item jz52-shuoshuo-item-single">
<header>
{if} $jz52_cfg->show_author == 1 {
<span>
{if} $jz52_moment->Avatar != '' {
<img src="{php}echo htmlspecialchars($jz52_moment->Avatar, ENT_QUOTES, 'UTF-8');{/php}" alt="" />
{else}
<span class="jz52-shuoshuo-avatar jz52-shuoshuo-avatar-text">{php}echo htmlspecialchars($jz52_moment->AuthorFirstChar, ENT_QUOTES, 'UTF-8');{/php}</span>
{/if}
<b>{php}echo htmlspecialchars($jz52_moment->AuthorName, ENT_QUOTES, 'UTF-8');{/php}</b>
</span>
{/if}
<span>
<time datetime="{$jz52_moment.TimeText}">{php}echo htmlspecialchars($jz52_moment->TimeText, ENT_QUOTES, 'UTF-8');{/php}</time>
</span>
{if} $jz52_isroot {
{if} $jz52_moment->IsPrivate <span>{$lang['Jz52_shuoshuo']['visible_private']}</span>{/if}
{if} $jz52_moment->IsPending <span>{$lang['Jz52_shuoshuo']['pending']}</span>{/if}
{/if}
</header>
<div>{$jz52_moment.Html}</div>
{if} $jz52_moment->MediaHtml != ''{{$jz52_moment.MediaHtml}{/if}
{* 留言区:三个片段模板(lm-shuoshuo-comments / -comment / -commentpost) *}
{if} $jz52_show_comments{template:lm-shuoshuo-comments}{/if}
<footer>
{if} count($jz52_moment->TagList) > 0 {
<span>
{foreach} $jz52_moment->TagList as $jz52_t {
<a href="{php}echo htmlspecialchars(Jz52_shuoshuo_ListUrl(1, $jz52_t), ENT_QUOTES, 'UTF-8');{/php}">#{php}echo htmlspecialchars($jz52_t, ENT_QUOTES, 'UTF-8');{/php}</a>
{/foreach}
</span>
{/if}
<span>{$lang['Jz52_shuoshuo']['views']} {$jz52_moment.ViewNums}</span>
{if} $jz52_cfg->like_enable == 1 {
<button type="button" class="jz52-shuoshuo-like{if $jz52_moment.IsLiked} is-liked{/if}" data-id="{$jz52_moment.ID}">
<span>{$jz52_moment.LikeNums}</span> {$lang['Jz52_shuoshuo']['like']}
</button>
{/if}
</footer>
</article>
<p><a href="{$jz52_listurl}">{$lang['Jz52_shuoshuo']['back_list']}</a></p>
{/if}
{* 点赞 / 留言 / 视频脚本:复用插件 JS(视频需引入 hls.js 与 artplayer.js,顺序固定) *}
<script type="text/javascript" src="{$zbp.host}zb_system/script/jquery-3.7.1.min.js"></script>
<script type="text/javascript" src="{$jz52_pluginurl}js/hls.min.js?v={$jz52_assets_ver}"></script>
<script type="text/javascript" src="{$jz52_pluginurl}js/artplayer.min.js?v={$jz52_assets_ver}"></script>
<script type="text/javascript">var Jz52ShuoshuoCfg = {likeUrl: "{$jz52_likeurl}", commentUrl: "{$jz52_commenturl}"};</script>
<script type="text/javascript" src="{$jz52_pluginurl}js/front.js"></script>
</body>
</html>7. Styling & Interaction Contracts
‑ Recommendation: reuse plugin‑supplied styles: Include <link rel="stylesheet" href="{$jz52_pluginurl}css/front.css" />. Override CSS selectors inside your theme stylesheet for custom appearance, for example classes .jz52‑shuoshuo‑wrap, .jz52‑shuoshuo‑item, .jz52‑shuoshuo‑like. If building fully custom styles, refer to class‑name structure inside plugin file css/front.css.
‑ Like‑button contract (required for working like feature):
Button markup:
<button class="jz52‑shuoshuo‑like" data‑id="moment‑id‑here">. Add CSS classis‑likedwhen visitor has liked this entry.Like‑count number must live inside element
<span class="jz52‑shuoshuo‑like‑num">.Page must load jQuery and plugin
js/front.js. Before loading front.js define global config variable:var Jz52ShuoshuoCfg = {likeUrl: "{$jz52_likeurl}"};.
‑ Time element best practice: Wrap formatted timestamp output inside <time datetime="…"> using value from property TimeText.
‑ List pagination: Variable $jz52_pager outputs complete pre‑rendered pagination HTML. For fully custom‑built pagination UI use variables $jz52_page, $jz52_totalPages together with helper function Jz52_shuoshuo_ListUrl($page, $tag).
Comment‑Section Interaction Contract
JavaScript logic inside front.js handles reply‑form movement, AJAX comment submission and scroll‑to‑anchor behaviour. If you customize partial templates lm‑shuoshuo‑comment.php or lm‑shuoshuo‑commentpost.php, you must preserve these exact class‑names and element IDs.
| Element | Requirements |
|---|---|
| Single comment item | <div class="jz52‑ss‑comment" id="cmt{ID}"> |
| Reply button | <a class="jz52‑ss‑cmt‑reply" data‑id="{ID}" data‑name="{display‑name}"> (contains reply icon / text label) |
| Outer form container | <div class="jz52‑ss‑cmt‑form" id="jz52CmtFormBox"> |
| Comment submission form | <form id="jz52CmtForm" method="post" action="{$jz52_cmt_posturl}">. Must contain hidden fields: inpId (moment ID), inpRevID (target‑reply‑ID defaults to 0), plus visible inputs inpName/inpEmail/inpHomePage/txaArticle. |
| AJAX insert anchor | After every comment item add marker <label class="jz52‑ss‑cmt‑anchor" id="AjaxComment{ID}"></label>. New AJAX‑submitted replies get inserted after this anchor element. |
| Cancel‑reply control | <a class="jz52‑ss‑cmt‑cancel" id="jz52CmtCancel" style="display:none;"> |
| Submit button | <button type="submit" id="jz52CmtSubmit"> |
| Live comment‑count display | Placeholder <span id="jz52CmtCount">{number}</span> in comment‑section heading, updated automatically after AJAX submit. |
Threaded nested‑reply recursion pattern inside
lm‑shuoshuo‑comment.php:
{foreach $jz52_cmt.Comments as $jz52_child}{php} $jz52_cmt = $jz52_child; $jz52_cmt_floor = 0; {/php}
{template:lm‑shuoshuo‑comment}
{/foreach}This recursion mechanism mirrors native Z‑Blog comment.php behaviour and works because template variables are promoted into global scope.
Video‑Player Contract (ArtPlayer + HLS)
Video attachments are rendered by plugin into container markup and initialized by front.js using ArtPlayer player library. Supports mp4 / webm and HLS .m3u8 streaming sources.
| Item | Requirements |
|---|---|
| Media container | Output markup <div class="jz52‑ss‑video" data‑src="video‑url" data‑poster="optional‑poster‑image">. Do not manually modify this HTML structure; always output via MediaHtml. When backend sets max‑player‑width, container gets CSS variable ‑‑jz52‑ss‑video‑maxw:{n}px for centering. Aspect‑ratio variable ‑‑jz52‑ss‑video‑ratio:{ratio} e.g. 9/16. Allowed ratio values whitelist: 16/9, 9/16, 4/3, 3/4, 1/1, 21/9. |
| Script loading sequence | Load scripts strictly in order: js/hls.min.js → js/artplayer.min.js → js/front.js. All three are mandatory for HLS stream decoding. |
| Player initialization | front.js auto‑scans for .jz52‑ss‑video DOM nodes and instantiates players. If ArtPlayer library is missing, initialization skips silently, showing black placeholder without throwing JavaScript errors. |
| Playback mutual exclusion | Plugin enforces only one video plays simultaneously on page. |
| Styling defaults | Plugin front.css supplies built‑in styles for .jz52‑ss‑video (rounded corners, black background, mobile responsiveness). Theme may override these styles. Containers default to full available width with aspect ratio 16:9. Backend configuration allows setting maximum width and custom aspect ratio (vertical‑video suggested width 360‑480 px). |
If you implement fully custom media rendering, you must replicate this container markup preserving attribute names
data‑srcanddata‑poster. URLs ending with.m3u8trigger automatic HLS decoding.
8. Language Pack Localization Strings
Avoid hard‑coded text. Reference plugin locale entries using syntax {$lang['Jz52_shuoshuo']['key‑name']}; text automatically adapts to site language setting.
| Key | Default Text | Usage |
|---|---|---|
all | All | Tag‑navigation "All" link label |
no_moments | No moments yet | Empty moments‑list hint |
back_list | Back to moments list | Detail‑page return‑link label |
visible_private | Private | Admin‑only private‑entry badge |
pending | Pending review | Admin‑only moderation‑status badge |
like | Like | Like‑button label |
views | Views | View‑count prefix label |
rss_subscribe | RSS Subscribe | RSS‑feed link label |
comments | Comments | Comment‑section heading |
comment_post | Post comment | Comment‑form heading |
reply | Reply | Reply‑button label |
cancel_reply | Cancel reply | Cancel‑reply control label |
no_comments | No comments yet | Empty‑comment‑list hint |
comment_closed | Comments are closed | Disabled‑comments notice |
submit_comment | Submit | Comment‑form submit‑button text |
cmt_name_placeholder / cmt_email_placeholder / cmt_home_placeholder | Nickname / Email / Website | Guest‑input placeholder texts |
cmt_content_placeholder | Write something… | Comment‑textarea placeholder |
9. Frequently Asked Questions (FAQ)
Q1: Theme template file is present but not taking effect / changes are not updating?Double‑check filename spelling lm‑shuoshuo.php and confirm file resides in your active theme’s template/ folder (not plugin directory). Go backend dashboard → click Clear Cache & Recompile Templates, or simply visit frontend moments page to trigger automatic template recompilation.
Q2: Page blank / HTTP 500 server error?Almost always caused by template syntax errors: multi‑line {if} conditional expressions, unclosed {php} blocks, misspelled variable identifiers. Inspect Z‑Blog log files zb_users/logs/*‑error*.txt and web‑server PHP error logs to locate exact line of failure.
Q3: Variable outputs empty value?Make sure all plugin‑supplied variables use prefix jz52_ (use $jz52_moments, not $moments). Core system variables $zbp, $lang do not take this prefix.
Remember {$raw_variable} outputs unescaped raw text; always pass user‑supplied plain‑text content through htmlspecialchars.
Q4: Can I use separate template files for list‑view and detail‑view?This plugin uses a single shared lm‑shuoshuo.php file. Branch logic differentiates page‑type via variable $jz52_type. This differs from native Z‑Blog category / tag templates. If you need file separation, use {template:your‑partial‑name} inside lm‑shuoshuo.php to load separate partial template files from your theme.
Q5: How are images / videos stored inside moment content rendered?Output {$jz52_moment.Html} for moment body text content, output {$jz52_moment.MediaHtml} for attached media assets (images, video, audio). Both contain fully‑processed HTML markup ready for direct output, do not escape them.
Q6: Can I view private / moderation‑pending moments?Frontend renders private and pending‑review entries only for logged‑in administrators (when $jz52_isroot equals true). Wrap status‑badge markup with condition {if $jz52_isroot} for admin visual cues.
Q7: Where is the like‑action API endpoint?Use variable $jz52_likeurl (POST request to cmd.php?act=jz52_shuoshuo_like, pass parameter id). AJAX handling is fully implemented within plugin js/front.js. Themes do not need custom backend logic for likes.
Q8: How do I customize comment section markup?Place overriding partial template files under theme template/: lm‑shuoshuo‑comments.php (overall comment‑section wrapper), lm‑shuoshuo‑comment.php (single‑comment + nested replies), lm‑shuoshuo‑commentpost.php (submission form). Override only files you want to change. You must preserve JavaScript‑contract DOM class‑names / IDs described in Chapter 7, otherwise reply and submit interactions break. After editing clear Z‑Blog template cache in backend.
Q9: If theme provides zero comment partial templates, will comment section throw errors?No error occurs. Plugin hook Filter_Plugin_Template_GetTemplate automatically falls back to plugin‑built‑in compiled partial templates. When theme supplies its own partial file, theme version takes priority.
Q10: How are floor numbers managed for threaded replies?Loop inside lm‑shuoshuo‑comments.php injects counter variable $jz52_cmt_floor counting top‑level root comments starting from 1. Inside single‑comment partial template show floor label only when {if $jz52_cmt_floor > 0} is true. Before recursive rendering for child nested replies, variable $jz52_cmt_floor gets reset to 0 so child replies omit floor number labels.
10. Theme Template Pre‑Delivery Checklist
‑ [ ] File is stored under path zb_users/theme/{theme‑folder}/template/lm‑shuoshuo.php‑ [ ] File starts with protection block: {php} if (!defined('ZBP_PATH')) { exit('Access denied'); } {/php} (prevents direct file‑access execution)
‑ [ ] All plugin‑provided template variables use jz52_ prefix
‑ [ ] User‑supplied plain‑text output is wrapped with htmlspecialchars escaping; pre‑rendered HTML properties (Html, MediaHtml, $jz52_pager) output directly without escaping
‑ [ ] List‑view logic wrapped inside {if $jz52_type == 'list'}, detail‑view accesses object $jz52_moment‑ [ ] Like‑button markup includes attribute data‑id, CSS class is‑liked toggle state, inner container .jz52‑shuoshuo‑like‑num for counter
‑ [ ] Detail page renders comment section: {if $jz52_show_comments}{template:lm‑shuoshuo‑comments}{/if}‑ [ ] When overriding comment‑partial templates: preserve JS‑contract DOM nodes: .jz52‑ss‑comment, .jz52‑ss‑cmt‑reply, form #jz52CmtForm, anchor marker AjaxComment{ID}‑ [ ] Video‑player container .jz52‑ss‑video preserves attributes data‑src / data‑poster. Script loading order is strictly enforced: hls.min.js → artplayer.min.js → front.js‑ [ ] Page loads plugin stylesheet front.css (or equivalent custom replacement styles), loads front.js with global config object Jz52ShuoshuoCfg containing commentUrl‑ [ ] After clearing backend template cache, verify all features work correctly: listing view, detail view, tag filtering, comment submit, video playback.
Document version 1.2 (compatible with plugin Jz52_shuoshuo 1.0.x; adds comment‑partial‑template documentation and ArtPlayer video‑player chapter). Author: Next‑Door‑Li.
Article link: https://docs.zbp.cool/lldocs/82.html
Helpful?
2026-10-15 11:20:39 From 重庆市
2026-10-15 11:09:06 From 江西省抚州市
2026-10-15 11:02:21 From 重庆市