function gettypepic($categoryId , $t="pc")
{
    while (true) {
        $category = db("arctype")->where("id",$categoryId)->find();
        if (empty($category) || empty($category['parent_id'])) {
            return $t=="pc" ? '/img/banner_about.jpg' : '';
        }
        if (!empty($category['image'])) {
            return $category['image']; // 如果图片不为空,返回当前栏目的 ID
        }
        $categoryId = $category['parent_id']; // 否则,继续查找父级栏目
    }
   
}

快捷键:sjtp

源:

sublime_text格式

<snippet>
    <content><![CDATA[
function gettypepic(\$categoryId , \$t="pc")
{
    while (true) {
        \$category = db("arctype")->where("id",\$categoryId)->find();
        if (empty(\$category) || empty(\$category['parent_id'])) {
            return \$t=="pc" ? '/img/banner_about.jpg' : '';
        }
        if (!empty(\$category['image'])) {
            return \$category['image']; // 如果图片不为空,返回当前栏目的 ID
        }
        \$categoryId = \$category['parent_id']; // 否则,继续查找父级栏目
    }
   
}
]]></content>
   <tabTrigger>sjtp(获取当前或上级栏目图片)</tabTrigger>
   <scope></scope>
</snippet>
点赞(0)

评论列表 共有 0 条评论

暂无评论
立即
投稿
发表
评论
返回
顶部