修改includes/bbcode.php里面的bbencode_first_pass函数可以增加BBCode,这个函数起到代码的转换作用,如果要在发表贴子的页面添加相应的工具按钮,我还没有仔细看,那样估计得修改模板,你可以先试一下。

解决方案 »

  1.   

    这里倒是有一个例子
    ################################################################################### 
    ## 
    ## Hack Title:    BBcode [center]..[/center]
    ## Hack Version:  1.0
    ## Author:        Acid < [email protected] >
    ## Description:   a new BBcode, so can center your text with the bbcode buttons
    ##
    ## Files to edit:   5
    ## includes/bbcode.php
    ## posting.php
    ##          language/lang_xxx/lang_main.php 
    ## templates/xxx/bbcode.tpl
    ## templates/xxx/posting_body.tpl 
    ## 
    ################################################################################### 
    ## 
    ## Note: 
    ## First always make a back-up from the files that you're going to edit. 
    ## 
    ################################################################################### 

    #-----[ ACTION: ]------------------------------------------ 
    # OPEN: includes/bbcode.php[FIND]:
    //  and  for italicizing text.
    $text = str_replace("','','','','','[code]','[/code]','[list]','[/list]','[list=]','[/list]','','','');[FIND IN THIS LINE]:
    '',''[ADD AFTER]:
    ,'[center]','[/center]'[FIND]:
      <input type="button" class="button" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onClick="bbstyle(16)" onMouseOver="helpline('w')" />
      </span></td>[ADD BELOW]:
    <td><span class="genmed"> 
      <input type="button" class="button" accesskey="y" name="addbbcode18" value=" Center " style="width: 60px" onClick="bbstyle(18)" onMouseOver="helpline('y')" />
      </span></td>[FIND]:
    <select name="addbbcode18" onChange="bbfontstyle('[color=' + this.form.addbbcode18.options[this.form.addbbcode18.selectedIndex].value + ']', '[/color]')" onMouseOver="helpline('s')">[REPLACE WITH]:
    <select name="addbbcode20" onChange="bbfontstyle('[color=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/color]')" onMouseOver="helpline('s')">NOTE: If you have additional bbcode mods installed you will need to increase the
          addbbcodeXX accordingly[FIND]:
    </select> &nbsp;{L_FONT_SIZE}:<select name="addbbcode20" onChange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">[REPLACE WITH]:
    </select> &nbsp;{L_FONT_SIZE}:<select name="addbbcode22" onChange="bbfontstyle('[size=' + this.form.addbbcode22.options[this.form.addbbcode22.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">NOTE: If you have additional bbcode mods installed you will need to increase the
          addbbcodeXX accordingly# 
    #----------------------------------------------------------------------------------------
    #----------------------------------------------------------------------------------------
    #----------------------------------------------------------------------------------------

      

  2.   

    但是我觉得最后的两个replace应该也是insert
    谁能解释一下 最好详细一点
      

  3.   

    这是控件命名的问题,为了编程的方便(标签都是成对出现),我们看到的名称都是偶数,由于前面加了一个居中控件,命名为addbbcode18,所以下面的名称要依次递加,如addbbcode20、addbbcode22等,如果要增加其它按钮也是类似,比如[fly][/fly]等,同时也感谢你提供的代码!
      

  4.   

    没看过PHPBB代码,说下通用思路吧:
    整页用ob缓存,在页面时ob_getcontents取得页面值,对该值进行若干正则及str_replace替换,实现目的。
    具体代码可以看下这个帖:
    http://be10.ods.org/knighte/viewthread.php?tid=102&fid=6