猫贝博客头像

猫贝博客

我愿奔赴大海

  • 文章4737
  • 阅读2289062

人生倒计时

  • 今日已经过去小时
  • 这周已经过去
  • 本月已经过去
  • 今年已经过去个月
首页 zblog教程 正文内容

zblog挂载接口往文章正文插入内容

猫贝 zblog教程 2021-12-18 10:44:40 2621

情况是这样的,假如你发布了很多文章,然后这个时候需要在每篇文章下面添加指定同样内容,那么就可以挂载下面接口。

image.png

首先第一步,在include.php的ActivePlugin函数里面挂载下面接口

Add_Filter_Plugin('Filter_Plugin_ViewPost_Template', 'ID_xxx');

然后第二步:新建一个方法,如下:

这里是小程序测试代码

p { color: red }

-----结束----


    ...这里是代码...
        ...这里是代码...
            ...这里是代码...

--------

header('Content-Type: image/png');
$img_one = glob(__DIR__ . "/resour/image/one/*.jpg",GLOB_BRACE); 
$img1 = array_rand($img_one);
$img_two = glob(__DIR__ . "/resour/image/two/*.png",GLOB_BRACE); 
$img2 = array_rand($img_two);
$img_three = glob(__DIR__ . "/resour/image/three/*.png",GLOB_BRACE); 
$img3 = array_rand($img_three);
$font = __DIR__ . '/resour/font/font.ttf';
$height = $width / 3 * 2;
$im = imagecreatetruecolor($width, $height);
$bg = imagecreatefromjpeg($img_one[$img1]); 
imagecopyresized($im,$bg,0,0,0,0,$width,$height,500,340);
imagecopyresized($im,imagecreatefrompng($img_two[$img2]),0,0,0,0,$width,$height,350,230);
imagecopyresized($im,imagecreatefrompng($img_three[$img3]),0,0,0,0,$width,$height,350,230);
if($zbp->Config('Cat_img')->aicolor){
$color = imagecolorallocate( $im, rand( 0, 255 ), rand( 0, 255 ), rand( 0, 255 ) );  
} else {
$color = imagecolorallocate( $im, 255, 255, 255 ); 
}

-------

<div class="111"></div>

-------

function ID_xxx(&$template) {
    global $zbp;
    $article = $template->GetTags('article');
    $article->Content = '前面内容'. $article->Content . '后面内容';
}

然后保存就OK啦,清除一下模板缓存。

广告
文章目录
    搜索