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>
发表评论 取消回复