首先打开网站模版目录/content/templates/,找到模板里header.php文件,打开后在<head></head>标签内添加如下代码:

<script src="//msite.baidu.com/sdk/c.js?appid=你的熊掌号ID"></script> 

  然后再找到模版目录下的echo_log.php文件,也是在<head>之间添加如下代码:


<script type="application/ld+json">
        {
            "@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
            "@id": "<?php echo Url::log($logid);?>",
            "appid": "1604715783902314",
            "title": "<?php echo $log_title; ?>",
            "images": [
               "<?php if(picthumb($logid)){echo picthumb($logid);}else{echo 'https://www.mosq.cn/content/templates/FLY/img/logo.png';}?>"
                ],
            "description": "<?php echo $site_description; ?>",
            "pubDate": "<?php echo gmdate('Y-m-d\TH:i:s', $date);?>",
            "upDate": "<?php echo gmdate('Y-m-d\TH:i:s', $date);?>",
            "lrDate": "<?php echo gmdate('Y-m-d\TH:i:s', $date);?>"
        }
    </script>

   上面的图片地址为默认图片地址,直接替换成你的即可。然后需要去模版公用核心函数module.php中添加一个获取第一张图片的function,代码如下


<?php
//getimage
function picthumb($blogid) {
  $db = MySql::getInstance();
  $sql = "SELECT * FROM ".DB_PREFIX."attachment WHERE blogid=".$blogid." AND (`filepath` LIKE '%jpg' OR `filepath` LIKE '%gif' OR `filepath` LIKE '%png') ORDER BY `aid` ASC LIMIT 0,1";
  //    die($sql);
  $imgs = $db->query($sql);
  while($row = $db->fetch_array($imgs)){
    $pict.= ''.BLOG_URL.substr($row['filepath'],3,strlen($row['filepath'])).'';
  }
  return $pict;
}
?>

  然后就可以在熊掌号的在线效验工具里测试一下有没有配置好

Emlog 熊掌号页面改造代码

本文作者:Author:     文章标题:Emlog 熊掌号页面改造代码
本文地址:https://www.mosq.cn/post-272.html     
版权说明:若无注明,本文皆为“森七博客”原创,转载请保留文章出处。
阿里云广告 淘宝优惠券
Last modification:February 7th, 2019 at 12:34 am
If you think my article is useful to you, please feel free to appreciate