Skip to main content
 首页 » 编程设计

jquery之用 jQuery 替换 dt 元素 (phpBB)

2026年07月28日7cmt

我尝试搜索,但我发现的所有示例和答案都无法使用。

phpBB 有以下几行代码:

    <!-- IF topicrow.S_FIRST_ROW or not topicrow.S_TOPIC_TYPE_SWITCH --> 
    <div class="forumbg<!-- IF topicrow.S_TOPIC_TYPE_SWITCH and (topicrow.S_POST_ANNOUNCE or topicrow.S_POST_GLOBAL) --> announcement<!-- ENDIF -->"> 
    <div class="inner"> 
    <ul class="topiclist"> 
        <li class="header"> 
            <dl class="row-item"> 
                <dt<!-- IF S_DISPLAY_ACTIVE --> id="active_topics"<!-- ENDIF -->><div class="list-inner"><!-- IF S_DISPLAY_ACTIVE -->{L_ACTIVE_TOPICS}<!-- ELSEIF topicrow.S_TOPIC_TYPE_SWITCH and (topicrow.S_POST_ANNOUNCE or topicrow.S_POST_GLOBAL) -->{L_ANNOUNCEMENTS}<!-- ELSE -->{L_TOPICS}<!-- ENDIF --></div></dt> 
                <dd class="posts">{L_REPLIES}</dd> 
                <dd class="views">{L_VIEWS}</dd> 
                <dd class="lastpost"><span>{L_LAST_POST}</span></dd> 
            </dl> 
        </li> 
    </ul> 

我正在尝试重新连接这部分(整条线)

<dt<!-- IF S_DISPLAY_ACTIVE --> id="active_topics"<!-- ENDIF -->> 
    <div class="list-inner"> 
        <!-- IF S_DISPLAY_ACTIVE -->{L_ACTIVE_TOPICS} 
        <!-- ELSEIF topicrow.S_TOPIC_TYPE_SWITCH and (topicrow.S_POST_ANNOUNCE or topicrow.S_POST_GLOBAL) -->{L_ANNOUNCEMENTS} 
        <!-- ELSE -->{L_TOPICS}<!-- ENDIF --> 
    </div> 
</dt> 

作为引用,我需要将其更改为

<dt<!-- IF S_DISPLAY_ACTIVE --> id="active_topics"<!-- ENDIF -->> 
    <div class="list-inner"> 
        <!-- IF S_DISPLAY_ACTIVE -->{L_ACTIVE_TOPICS} 
        <!-- ELSEIF topicrow.S_TOPIC_TYPE eq 3 -->{L_GLOBAL_ANNOUNCEMENTS} 
        <!-- ELSEIF (topicrow.S_POST_ANNOUNCE or topicrow.S_POST_GLOBAL) eq 2 -->{L_ANNOUNCEMENTS} 
        <!-- ELSEIF topicrow.S_TOPIC_TYPE eq 1 -->{L_STICKY} 
        <!-- ELSE -->{L_TOPICS}<!-- ENDIF --> 
    </div> 
</dt> 

有人可以提供我需要的完整 jquery 代码吗?谢谢。

请您参考如下方法:

phpBB仅禁止修改核心php文件。如果要修改数据,就必须使用扩展。但你不属于这种情况。

对于模板,建议使用事件模板扩展,尤其是当您必须添加一些新功能时。但您可以更改您的模板,尤其是针对您的案例!

这是好的做法:

继承prosilver创造新风格

# General Information about youstyle 
name = mystyle 
copyright = © phpBB Limited, 2016 
style_version = 3.1.10 
phpbb_version = 3.1.10 
 
# Defining a different template bitfield 
# template_bitfield = lNg= 
 
# Parent style 
# Set value to empty or to this style's name 
# if this style does not have a parent style 
parent = prosilver 

复制/粘贴模板文件viewforum.phtml ,你想改变你的新样式目录并直接改变它。

phpBB/styles/mystyle/template/viewforum_body.html 

使用您的管理面板来测试您的修改。完成后,将默认模板从 prosilver 更改为 mystyle

这里有一个关于 template Inheritance 的很好的文档