Emlog模板制作之面包屑导航(参考教程)

时间:2020-08-01   阅读:306

今天看论坛看到此文章的,虽然比较复杂,但还是很有用的,这里写出来供大家参考,这次写出来我也不知道这是不是很全面吧,不过我估计能有的我都给写进去了。

使用方法:
将以下代码放入模板文件module.php中

<?php
$sheli_mbx = "首页";

if( $params[1]=='page' ){
    $sheli_mbx .= htmlspecialchars(urldecode($params[2]));//获取第某页
}

function __breadcrumb_Sort_Cache($id){
    global $CACHE;
    $sort_cache = $CACHE->readCache('sort');
    return $sort_cache[$id]['sortname'];
}

function __breadcrumb_User_Cache($id){
    global $CACHE;
    $user_cache = $CACHE->readCache('user');
    return $user_cache[$id]['name'];
}

function __breadcrumb_Blog_Sort_Cache_Check($blogid){
    global $CACHE; 
    $log_cache_sort = $CACHE->readCache('logsort');
    if(!empty($log_cache_sort[$blogid])){
        return true;
    }else{
        return false;
    }
}

function __breadcrumb_Blog_Sort_Cache($blogid){
    global $CACHE; 
    $log_cache_sort = $CACHE->readCache('logsort');
    if(!empty($log_cache_sort[$blogid])){
        //分类名称:$log_cache_sort[$blogid]['name']
        //分类链接:Url::sort($log_cache_sort[$blogid]['id'])
        return $log_cache_sort[$blogid]['name'];
    }
}

if( $params[1]=='sort' ){//分类
    //分类名称:_cache_breadcrumb_Sort_Cache($sortid)
    //分类链接:$sort_url = Url::sort($sortid);
    $sheli_mbx .= __breadcrumb_Sort_Cache($sortid);
    if( $params[4]=='page' ){
        $sheli_mbx .= htmlspecialchars(urldecode($params[5]));//获取第某页
    }
}elseif($params[1]=='record'){//归档
    $sheli_mbx .= $params[2];
    if( $params[4]=='page' ){
        $sheli_mbx .= htmlspecialchars(urldecode($params[5]));//获取第某页
    }
}elseif( $params[1] == 'author' ){//文章
    //作者名称:_cache_breadcrumb_User_Cache($params[2])
    //作者链接:$author_url = Url::author($params[2]);
    $sheli_mbx .= __breadcrumb_User_Cache($params[2]);
    if( $params[4]=='page' ){
        $sheli_mbx .= htmlspecialchars(urldecode($params[5]));//获取第某页
    }
}elseif( $params[1] == 'tag' ){//标签
    //标签名称:htmlspecialchars(urldecode($params[2]));
    //标签链接:$tag_url = Url::tag($params[2]);
    $sheli_mbx .= htmlspecialchars(urldecode($params[2]));
    if( $params[4]=='page' ){
        $sheli_mbx .= htmlspecialchars(urldecode($params[5]));//获取第某页
    }
}elseif( $params[1] == 'keyword' ){//搜索
    $sheli_mbx .= htmlspecialchars(urldecode($params[2]));
    if( $params[4]=='page' ){
        $sheli_mbx .= htmlspecialchars(urldecode($params[5]));//获取第某页
    }
}elseif( $type=='blog' ){//自定义文章
    
    //判断文章是否存在分类
    if( __breadcrumb_Blog_Sort_Cache_Check($logid) ){
        $sheli_mbx .= __breadcrumb_Blog_Sort_Cache($logid);
    }
    
    //文章名称:$log_title
    //文章链接:Url::log($logid);
    $sheli_mbx .= $log_title;
}elseif( $type=='page' ){//自定义文章
    $sheli_mbx .= $log_title;
}elseif( $tws ){
    
    preg_match_all('|^.*/\?(page)=(\d+)([\?&].*)?$|',Dispatcher::setPath(),$Preferred);
    if( $Preferred[1][0]=='page' ){
        $sheli_mbx .= htmlspecialchars(urldecode($Preferred[2][0]));
    }
    
    $sheli_mbx .= '微语';
};?>

最后在你需要的位置放入<?php echo $sheli_mbx;?>即可完工,至于CSS什么的,自己折腾吧。

上一篇:关于emlog评论当网址、昵称、内容等相同时无法提交的判断

下一篇:教程:EMLOG博客非插件实现一键点赞功能介绍

网友评论