Menu

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

This article was last updated 31 days ago, please note whether the content is still available

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

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

PriorityTemplate FileDescription
1 (Highest)zb_users/theme/{current‑theme}/template/lm‑shuoshuo.phpTheme‑provided moments‑page template, fully controlled by the theme author
2 (Fallback)zb_users/plugin/Jz52_shuoshuo/template/shuoshuo.phpPlugin 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):

  1. After placing or editing the template file, simply visit the frontend moments page. The system will detect template changes and recompile automatically.

  2. 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.php and 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 FilePurpose
lm‑shuoshuo‑comments.phpMain comment‑section template: includes title with comment count, comment‑item loop, empty‑state prompt, and form / closed‑comments notice
lm‑shuoshuo‑comment.phpSingle‑comment item: avatar, username, content, floor number, reply button; supports recursive nested replies
lm‑shuoshuo‑commentpost.phpComment 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.php without any partial template files, the plugin will automatically fall back to its built‑in partial templates without throwing errors. This is implemented via the Filter_Plugin_Template_GetTemplate hook.

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.

SyntaxDescriptionExample
{$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 pairsSee tag‑navigation example
{for expression} … {/for}Numeric for‑loop{for $i=1; $i<3; $i++}
{switch …}Switch‑case branchRarely 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 / method TagList.

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)

VariableTypeDescription
$jz52_typestringPage type: 'list' (moments listing), 'single' (single moment detail)
$jz52_cfgobjectPlugin configuration object ($zbp‑>Config('Jz52_shuoshuo')). See below for common keys.
$jz52_isrootboolWhether current visitor is an administrator
$jz52_can_postboolWhether 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_uploadboolWhether visitor may upload images inside the composer box (separately controlled by backend permission setting). Use this to show / hide image upload button.
$jz52_posturlstringFrontend publish API endpoint URL (POST fields: content + csrfToken + media)
$jz52_uploadurlstringFrontend image upload API endpoint URL (POST fields: file + csrfToken)
$jz52_pluginurlstringPlugin directory URL e.g. http://your‑domain/zb_users/plugin/Jz52_shuoshuo/; used to load plugin CSS / JavaScript assets
$jz52_likeurlstringLike‑submit API endpoint URL (POST request)
$jz52_rssurlstringRSS feed URL
$jz52_listurlstringBase URL for moments listing homepage
$jz52_allurlstringURL for "All‑tags" filter, equivalent to page‑1 listing without tag filtering
$jz52_titlestringComplete HTML <title> page title
$jz52_pageTitlestringMain page heading; equals section name for list page, moment title or excerpt for detail page

List‑Page‑Only Variables

VariableTypeDescription
$jz52_pageintCurrent page number (starts from 1)
$jz52_totalPagesintTotal page count
$jz52_tagstringCurrently‑filtered tag name; empty string when no tag filter is active
$jz52_tagsarrayTag statistics array format: tag‑name => post‑count; used to render tag navigation
$jz52_momentsarrayArray of moment objects for current page (Jz52_shuoshuo[]). See Chapter 4 for object properties.
$jz52_pagerstringPre‑rendered pagination HTML string; empty string '' if only one page exists. Check with condition {if $jz52_pager != ''}.

Detail‑Page‑Only Variables

VariableTypeDescription
$jz52_momentobjectTarget single‑moment object (Jz52_shuoshuo). Properties described in Chapter 4.

Detail‑Page Comment‑Section Variables (only present on detail view)

VariableTypeDescription
$jz52_show_commentsboolAlways true on detail page; not injected for listing pages. Use to conditionally render comment section.
$jz52_commentsarrayTop‑level root‑level comment object array (Jz52_shuoshuo_Comment[]). Nested child replies are pre‑attached under property Comments.
$jz52_comment_countintTotal number of approved comments
$jz52_comment_enabledboolMaster switch for comment functionality (backend config key comment_enable)
$jz52_cmt_posturlstringComment submit API endpoint URL (cmd.php?act=jz52_shuoshuo_comment_post)
$jz52_cmt_logged_inboolWhether visitor is currently logged‑in
$jz52_cmt_user_name / $jz52_cmt_user_email / $jz52_cmt_user_homestringLogged‑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_comments is available.

Core System Variables (no jz52_ prefix, do not add prefix)

VariableDescription
$zbpGlobal Z‑Blog core object. Common uses: {$zbp.name} (site name), {$zbp.host} (site base URL).
$langLanguage pack object; retrieve plugin locale strings with {$lang['Jz52_shuoshuo']['key‑name']} (see Chapter 8).

Plugin‑Config Keys ($jz52_cfg‑>key‑name)

KeyTypeDefaultDescription
titlestringMomentsSection display name
pagesizeint10Items shown per page
like_enableint1Toggle like feature (1 = on, 0 = off)
rss_enableint1Toggle RSS feed (1 = on, 0 = off)
show_authorint1Toggle frontend author‑name display (1 = on, 0 = off)
post_enableint1Toggle 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)

PropertyTypeDescription
IDintUnique moment entry ID
AuthorIDintPublishing user ID
TitlestringMoment title (can be empty string)
ContentstringRaw plain‑text content
HtmlstringPre‑rendered moment HTML. Line‑breaks converted to <br>. Output directly with {$jz52_moment.Html}, do not escape.
MediastringMedia metadata stored as JSON string
TagsstringRaw tag string in format ,tag1,tag2,. Usually use property TagList instead.
VisiblestringVisibility setting: public / private
ApprovedboolModeration approval status
IsTopintPin‑to‑top flag (1 = pinned)
LikeNumsintLike count number
ViewNumsintView count number
PostTimeintUnix timestamp of publish time; use TimeText for human‑readable formatted output
CreateTime / UpdateTimeintUnix timestamps for record creation / last modification

Computed Read‑Only Properties (usable directly in templates)

PropertyTypeDescription
UrlstringURL to moment detail page
AuthorobjectZ‑Blog Member object for author; empty dummy member for guests, check validity with ID <= 0
AuthorNamestringDisplay‑ready author name (nickname or username)
AuthorFirstCharstringFirst character of author’s display name; used for text‑based fallback avatar
AvatarstringAvatar image URL; empty string for guest / missing avatar
TagListarrayNormalized tag‑name array e.g. array('test','moments')
MediaHtmlstringPre‑rendered HTML markup for attached media (images, video, audio). Empty string if no attachments. Output directly.
TimeTextstringHuman‑readable localized timestamp adjusted for site timezone
SubContentstringShort excerpt limited to first 30 characters of content
IsLikedboolWhether current visitor has liked this entry (tracked via browser Cookie)
IsPrivateboolConvenience flag equivalent to Visible == 'private'
IsPendingboolConvenience 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:

PropertyTypeDescription
IDintUnique comment ID
NamestringCommenter display‑name; input sanitized on save, still recommend htmlspecialchars before HTML output
HomePagestringCommenter website URL; sanitized on database save, only valid http(s) links are preserved
ContentstringRaw unescaped comment text
PostTimeintUnix timestamp for comment submission
IsCheckingintModeration pending flag (1 = pending review)
AuthorobjectZ‑Blog Member object for logged‑in comment authors; empty dummy member for guests (ID <= 0, Avatar empty)
AvatarTextstringFirst‑character text for fallback text avatar
HomeLinkstringSanitized valid http(s) homepage URL; empty string for invalid / missing values; use to conditionally render anchor <a> tag
ContentHtmlstringFully‑processed safe HTML for comment content (HTML escaping, auto‑link conversion, newline handling). Output directly: {$jz52_cmt.ContentHtml}.
IsCheckingBadgestringPre‑rendered HTML badge "Pending Review", visible only for admin users; empty string for guests, output directly
TimeTextstringHuman‑readable formatted comment timestamp
CommentsarrayNested child‑reply comment array for threaded replies
LevelintComment 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)

FunctionDescription
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 class is‑liked when 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.

ElementRequirements
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 anchorAfter 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 displayPlaceholder <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.

ItemRequirements
Media containerOutput 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 sequenceLoad scripts strictly in order: js/hls.min.js → js/artplayer.min.js → js/front.js. All three are mandatory for HLS stream decoding.
Player initializationfront.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 exclusionPlugin enforces only one video plays simultaneously on page.
Styling defaultsPlugin 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‑src and data‑poster. URLs ending with .m3u8 trigger 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.

KeyDefault TextUsage
allAllTag‑navigation "All" link label
no_momentsNo moments yetEmpty moments‑list hint
back_listBack to moments listDetail‑page return‑link label
visible_privatePrivateAdmin‑only private‑entry badge
pendingPending reviewAdmin‑only moderation‑status badge
likeLikeLike‑button label
viewsViewsView‑count prefix label
rss_subscribeRSS SubscribeRSS‑feed link label
commentsCommentsComment‑section heading
comment_postPost commentComment‑form heading
replyReplyReply‑button label
cancel_replyCancel replyCancel‑reply control label
no_commentsNo comments yetEmpty‑comment‑list hint
comment_closedComments are closedDisabled‑comments notice
submit_commentSubmitComment‑form submit‑button text
cmt_name_placeholder / cmt_email_placeholder / cmt_home_placeholderNickname / Email / WebsiteGuest‑input placeholder texts
cmt_content_placeholderWrite 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.

Ultimate · Let's Talk (Jz52_shuoshuo) Plugin Template Creation Tutorial.pdf
Download this article as a PDF document and save it
Export PDF

Helpful?

Comments(3)



云端漫步者
云端漫步者

2026-10-15 11:20:39 From 重庆市

这么好的模板文档写得像教科书一样完整,可惜我是那种看两行代码就想睡觉的人。
**雾隐代码师**
**雾隐代码师**

2026-10-15 11:09:06 From 江西省抚州市

文档写得够细,变量前缀防冲突、片段覆盖兜底、JS 契约说明都到位,但变量表太长像字典,建议加一页快速上手示例;另外代码块没语法高亮,手机端复制不便。
星坠雾海
星坠雾海

2026-10-15 11:02:21 From 重庆市

文档把插件模板覆盖机制和变量契约讲得足够透彻,尤其前缀命名规范和片段兜底设计很贴心,就是JS DOM契约那段类名太多,初次定制留言区时得对照着插件源码才能不跑偏。

Post comment

Support Live Chat
TOP