thinkphp6自定义标签
public function tagTitle()
{
    $parse = '<?php ';
    $parse .= '$tagChannel = new app\common\taglib\ht\tagTitle;';
    $parse .= '$data = $tagChannel->createTitle();';
    $parse .= 'echo $data;';
    $parse .= 'unset($data)';
    $parse .= ' ?>';
    return $parse;
}public function createTitle()
{
    $t = '';
    $k = '';
    $d = '';
    $Config = cache("Config");
    $aid = input('param.aid/d', '');
    $tid = input('param.tid/d', '');
    $pid = input('param.pid/d', '');
    $title = "<title>%s</title>\n\t<meta name=\"description\" content=\"%s\"/>\n\t<meta name=\"keywords\" content=\"%s\"/>\n";
    if (empty($aid) && empty($tid) && empty($pid)) {  // 都为空 认为是首页
        $t = !empty($Config["web_title"]) ? $Config["web_title"] : $Config["web_name"];
        $k = !empty($Config["web_keywords"]) ? $Config["web_keywords"] : $Config["web_name"];
        $d = !empty($Config["web_description"]) ? $Config["web_description"] : $Config["web_name"];
    }
    if (!empty($aid)) { // 内容页
        $tagarticle = Archives::find($aid);
        $t = !empty($tagarticle['title']) ? $tagarticle['title'] . "-" . $Config["web_name"] : $Config["web_name"];
        $k = !empty($tagarticle['seo_key']) ? $tagarticle['seo_key'] : $Config["web_keywords"];
        $d = !empty($tagarticle['seo_des']) ? $tagarticle['seo_des'] : $Config["web_description"];
        unset($tagproduct);
    }
    if (!empty($tid)) { // 栏目页面
        $tagarctype = Arctype::find($tid);
        $t = !empty($tagarctype['seo_title']) ? $tagarctype['seo_title'] : $tagarctype["title"]."-".$Config["web_name"];
        $k = !empty($tagarctype['seo_key']) ? $tagarctype['seo_key'] : $Config["web_keywords"];
        $d = !empty($tagarctype['seo_des']) ? $tagarctype['seo_des'] : $Config["web_description"];
        unset($tagarctype);
    }
    if (!empty($pid)) { // 产品页面
        $tagproduct = Goods::find($pid);
        $t = !empty($tagproduct['seo_title']) ? $tagproduct['seo_title'] : $tagproduct["title"]."-".$Config["web_name"];
        $k = !empty($tagproduct['seo_key']) ? $tagproduct['seo_key'] : $Config["web_keywords"];
        $d = !empty($tagproduct['seo_des']) ? $tagproduct['seo_des'] : $Config["web_description"];
        unset($tagproduct);
    }
    return sprintf($title, htmlentities($t),htmlentities($d),htmlentities($k));
}然后就可以在模板中调用标签了
{ht:title}会自动生成title标题,Description描述,Keywords关键词
