分类 cms 下的文章

<input type="text" id="keyword"><button id="so">搜索</button>
<ul id="data"></ul>
<button class="ajaxMore" style="display: none">加载更多</button>
<script type="text/javascript">
let curpage = 1;
let limit=15;
let sum =0;
let _fields='id,tid,title,keywords,description,litpic,body,htmlurl,target,addtime';
let _serUrl ="/GetData/getDataSearch.html";
let _model='article';
let _key='232323';
let _word = '';
let _title = 'title';
$("#so").click(function(){
    _word = $("#keyword").val();
    let  html='';
    $.ajax({
     url:_serUrl,
     dataType:"json",
     async:true,
     data:{model:_model,key:_key,search:_title,word:_word,fields:_fields,limit:limit,page:curpage},
     type:"POST",
     success:function(r){
         console.log(r);
            sum = r.sum;
             if(sum>=1&&sum<=limit){
                 $(".ajaxMore").show().html('没有更多了!');
            }else if(sum>limit){
                  $(".ajaxMore").show();
            }else{
                $(".ajaxMore").show().html('无相关数据');
            }
            $("#data").html('');
                for(const item of r.data){
                  html+=`<li><h4>${item.title}</h4></li>`;
                }
           $("#data").html(html);    
    },
     error:function(){

    }
    })

})
    
$(".ajaxMore").click(function(){
        curpage++;    
        let html = '';
        $.ajax({
             url:_serUrl,
             dataType:"json",
             async:true,
             data:{model:_model,key:_key,search:_title,word:_word,fields:_fields,limit:limit,page:curpage},
             type:"POST",
             success:function(r){
                 if(r.data.length>0){
                     let allpage = r.allpage;
                    if(curpage<=allpage){
                        if(r.data.length<limit){
                           $(".ajaxMore").text('没有更多了!');
                         };
                        for(const item of r.data){
                              html+=`<li><h4>${item.title}</h4></li>`
                         }
                        $("#data").append(html);
                         

                       }
               }

             }
        })


})


</script>

找到\app\index\taglib\HkCms.php,给breadcrumb添加home字段调用

'breadcrumb'  => ['attr'=>'catid,symbol,home,class,currentstyle,isclick', 'close'=>0],

找到tagBreadcrumb函数添加home默认值;

public function tagBreadcrumb($tag)
    {
        $tag['symbol'] = $tag['symbol'] ?? ' > ';
        $tag['class']   = $tag['class'] ?? '';
        $tag['home']   = $tag['home'] ?? '首页';

找到\app\index\model\cms\Category.php里面getBreadcrumb函数调用 $tag['home'];

 public function getBreadcrumb($tag, $cate = [])
    {
        $home_url = '/';
        //$home_title = lang("Home");
        $home_title = $tag['home'];

        $catid = !empty($tag['catid']) ? $tag['catid'] : ($cate['id']??'');
        if (empty($catid)) {
            return '';
        }

模板里面使用

{hkcms:breadcrumb home="这是自定首页字符串" class="active_a" symbol=" / " /}

app/index/controller/index.php 按照以下代码修改
class Index extends BaseController

{
    protected $middleware = [ // 限制index,show方法需要登录
        \app\index\middleware\Login::class=> ['only'=>['download']]
    ];
    public function initialize()
    {
        parent::initialize();

        // 非开发者模式下,屏蔽非致命错误
        if (!$this->app->isDebug()) {
            // 屏蔽掉notice错误
            //error_reporting(E_ERROR & ~E_WARNING & ~E_NOTICE);
            error_reporting(E_ERROR);
        }

        //前台模板调用会员信息s
        $this->user = \app\index\library\User::instance();
        $user = $this->user->getUser();
        if ($user) {
            $user['group'] = $this->user->getGroups($user['id']);
        }
        $this->view->assign('user', $user);
       //前台模板调用会员信息e

    }