了无痕

性别:保密

地区:IANA

主页 提问 回答

提问更多

回答更多

  • 如何在小说详情页面调用章节内容

    没看到官网怎么解决的,也没有个默认模版来参考,只能瞎研究代码。

    目前个人解决方法如下:

    1、打开路径:网站根目录/sys/apps/models/Tpl.php

    2、找到:
    //获取模板
    $str = load_file('book/info.html');

    3、在这段的代码上面,增加下面代码:
    //获取第一章txt 开始
    $tables = get_chapter_table($row['id']);
    $row['tables']=$tables;
    //基于xid和bid 共同获取章节id
    $conditions = [
    'xid' => 1, // 是要查询的 xid 值(这里只获取第一个章节)
    'bid' => $row['id']
    ];
    $rowwww = $this->mcdb->get_row_arr($tables, '*', $conditions);
    if ($rowwww) {
    $row['fbid2'] = $rowwww['id'];
    }
    $row['ftxt'] = get_book_txt($row['id'],$row['fbid2']);
    $row['ftxt'] = ''.preg_replace('/s+/s','',$row['ftxt']).'';//替换为p段落
    //获取第一章txt 结束

    4、在模版info.html中使用 [book:ftxt] 调用。

    ps:其他扩展请自行修改。如有更好的方法,请分享。
    1