zblog 常用调用标签代码
文章目录
1、循环里
{$host} 博客网址 {$name} 博客标题 标题控制字数: {php}echo mb_substr($article->Title, 0, 16, 'UTF-8');{/php} <!-- 列表,摘要 --> {php}$description = preg_replace('/[\r\n\s]+/', '', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),120)).'...');{/php} {$description} {ok_tu($article)} {tupian($article)} {php} // 使用带缓存的图像裁剪函数 $img_url= sb_cache(tupian($article), 213, 135); // 处理文章简介 $description = preg_replace('/[\r\n\s]+/', '', trim(SubStrUTF8(TransferHTML($article->Content, '[nohtml]'), 120)) . '...'); {/php} {$img_url} {$description} <li><a href=" {$article.Url} "> {$article.Title} </a></li> 发表时间: {$article.Time("PostTime","Y-m-d H:i:s")} {$article.Time("PostTime","Y-m-d ")} 浏览数:{$article.ViewNums} 文章信息: 所属分类 {$article.Category.Name} 所属分类链接 {$article.Category.Url} 浏览量:{$article.ViewNums} {$article.ViewNums} {$article.Category.Count} 分类信息: 分类名称 {$category.Name} 分类别名 {$category.Alias} 分类链接 {$category.Url} 分类文章数量: {$category.Count} <img src="{tupian($article,200,128)}" alt="{$article.Title}" title="{$article.Title}"> // 示例:调用函数显示相对时间 $articleTime = $article->Time(); // 获取文章的发布时间,假设它是一个字符串形式的日期时间 $relativeTime = shijian($articleTime); {php} $articleTime = $article->Time(); echo $relativeTime = shijian($articleTime); {/php}
2、分离调用
{template:inc/seo} {* 调用SEO标题 *} {template:header} {template:footer} {template:sidebar} {template:breadcrumb} {template:pc/menu} {* 菜单*} {template:m/m} {* 菜单*} {template:m/header} {template:m/footer} {template:public/ad} {* 广告*} {template:pc/menu} {* 菜单*} {template:sb/css} {* 分离css*}
3、 导航
{module:navbar2} {php} global $zbp; // 获取导航栏模块内容 $moduleContent = $zbp->modulesbyfilename['navbar']->Content; // 创建 DOMDocument 对象 $doc = new DOMDocument('1.0', 'UTF-8'); @$doc->loadHTML('<?xml encoding="UTF-8">' . $moduleContent); // 获取所有带有 的链接元素 $navbarItems = $doc->getElementsByTagName('a'); foreach ($navbarItems as $item) { $href = $item->getAttribute('href'); $title = $item->getAttribute('title'); $name = $item->nodeValue; echo '<li class="nav-item li_b6d767d2f8">'; echo '<a class="nav-link d-flex align-items-center px-2 py-3 a_b6d767d2f8" href="' . $href . '" title="' . $title . '">' . $name . '</a>'; echo '</li>'; } {/php}
4、常用路径调用
{$host}zb_users/theme/{$theme}/images/ {$host}zb_users/theme/{$theme}/imgm/ banner logo search {template:m/mb/logo} {* 调用logo*} {template:m/mb/search} {* 调用搜索 *} {template:m/mb/banner} {* 调用焦点图 *} {template:m/mb/msn} {* 调用菜单 *} {$host}zb_users/theme/{$theme}/img/logo/logos.png {$host}zb_users/theme/{$theme}/img/logo/logo.png {$host}zb_users/theme/{$theme}/img/nav/nav1.png {$host}zb_users/theme/{$theme}/img/nav/nav2.png {$host}zb_users/theme/{$theme}/img/nav/nav3.png {$host}zb_users/theme/{$theme}/img/nav/nav4.png {$host}zb_users/theme/{$theme}/img/wx/wei01.png mlogo.png logo.png {$host}zb_users/theme/{$theme}/img/weixin/wei01.jpg {$host}zb_users/theme/{$theme}/img/weixin/wei02.jpg {$host}zb_users/theme/{$theme}/img/banner/banner.jpg {$host}zb_users/theme/{$theme}/img/banner/cat_banner1.jpg {$host}zb_users/theme/{$theme}/img/banner/single_banner1.jpg {$host}zb_users/theme/{$theme}/img/about/about66.jpg {$host}zb_users/theme/{$theme}/img_pc/ {$host}zb_users/theme/{$theme}/imgs/
5、常用局部调用列表
{php} $mn_st1 = $zbp->Config('gs_ai')->mn_st1; // 将字符串转换为数组,移除空值并确保每个值是整数 $mn_st1 = explode(',', $mn_st1); $mn_st1 = array_filter(array_map('intval', $mn_st1)); // 转换为整数并移除空值 $mn_cat1 = $zbp->Config('gs_ai')->mn_cat1; // 将字符串转换为数组,移除空值并确保每个值是整数 $mn_cat1 = explode(',', $mn_cat1); $mn_cat1 = array_filter(array_map('intval', $mn_cat1)); // 转换为整数并移除空值 $mn_cout1 = $zbp->Config('gs_ai')->mn_cout1; // 获取自定义文章和分类文章 $customPostr = get_id_cat_xin($mn_st1, $mn_cat1, $mn_cout1); {/php} {foreach $customPostr as $article} <div> <a href="{$article.Url}" target="_blank"> <img src="{tupian($article)}" alt="{$article.Title}"> </a> </div> {/foreach}
6、友情链接 备案 统计 底部
{php} echo get_friend_links(); {/php} {template:ins/link} {* 友情链接*} {if $zbp->Config('mei')->ban_b_on} {$zbp->Config('mei')->ban_b} {* 网站底部 *} {/if} {if $zbp->Config('mei')->ban_c_on} {$zbp->Config('mei')->ban_c} {* 网站备案 *} {/if} {if $zbp->Config('gs_dana')->ad_hi_a1} {$zbp->Config('gs_dana')->ad_si_a1} {* 文章ads *} {/if} {if $zbp->Config('mei')->tongji} {$zbp->Config('mei')->tongji} {* 百度统计 *} {/if}
7、分类,列表页
{foreach $articles as $article} {if $article.IsTop} {else} {/if} {/foreach} {template:list} {* 循环*} {template:public/list} {* 循环*} {template:public/lise} {* 循环*} {template:pc/list_pc} {* 循环*} {template:m/list_m} {* 循环*} {php} {/php} {template:pagebar} {* 分类翻页 *} 标题控制字数: {php}echo mb_substr($article->Title, 0, 16, 'UTF-8');{/php} <!-- 列表,摘要 --> {php}$description = preg_replace('/[\r\n\s]+/', '', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),120)).'...');{/php} {$description} {ok_tu($article)}
8、最新/置顶文章
最新文章: {foreach GetList(10) as $article} {/foreach} 某个分类 {foreach GetList(12,$article.Category.ID) as $article} <li><a href=" {$article.Url} "> {$article.Title} </a></li> {/foreach} {$topArray = GetList(8, null, null, null, null, null, array("only_ontop" => true));} <ul> {foreach $topArray as $article} <li><a href="{$article.Url}" target="_blank"> <img src=" {mei_thumbnail($article)}"> <div> <h2>{$article.Title} </h2> <p></p> <div class="intr-tag fixed"> <!--<span>python</span> --> </div> </div> </a></li> {/foreach}
9、文章页相关tag标签
{php} // 文章页面调用,文章标签,最多不能超过3个,如果没有标签就调用分类 $articleTags = $article->Tags; $tagCount = count($articleTags); if ($tagCount > 0) { // 如果文章有标签,显示最多3个标签 $displayedTags = 0; foreach ($articleTags as $tag) { echo '<span><a target="_blank" href="' . $tag->Url . '">' . $tag->Name . '</a></span> '; $displayedTags++; if ($displayedTags >= 3) break; } } else { // 如果没有标签,显示文章所属的分类 echo '<span> <a target="_blank" href="' . $article->Category->Url . '">' . $article->Category->Name . '</a> </span>'; } {/php}
新文章标签
{$article.Title} {template:ins/post_ad1} {* 文章顶部广告 *} {if $zbp->Config('gs_gpt')->mulu} {template:ins/mulu} {* 文章h2索引目录 *} {/if} {template:ins/edit} {* 文章编辑 *} {$article.Content} {template:ins/ad2} {* 文章底部广告 *} </div> {if $zbp->Config('gs_gpt')->p_tag} {template:ins/tag} {* 文章标签 *} {/if} {template:ins/copyright} {* 版权信息 *} {template:ins/next} {* 上下一篇 *} {template:ins/xg} {* 相关文章 *}
10、文章相关推荐
{php} // 获取同分类的最新30篇文章 $categoryArticles = $zbp->GetPostList('*', array(array('=', 'log_CateID', $article->Category->ID)), array('log_PostTime' => 'DESC'), 30, null); // 从这些文章中随机选择8篇 shuffle($categoryArticles); $randomSelectedArticles = array_slice($categoryArticles, 0, 9); {/php} {foreach $randomSelectedArticles as $article} <div class="hentry ht_grid_1_3"> <a href="{$article.Url}"> <div> <img width="280" height="176" src=" {tupian($article)}" class="attachment-zimeiti_1_list_thumb size-zimeiti_1_list_thumb wp-post-image" alt="" decoding="async" loading="eager" /> </div> </a> <h2> <a href="{$article.Url}"> {$article.Title} </a> </h2> </div> {/foreach}
同分类的最新30篇文章, 从这些文章中随机选择8篇 {php} // 获取同分类的最新30篇文章 $categoryArticles = $zbp->GetPostList('*', array(array('=', 'log_CateID', $article->Category->ID)), array('log_PostTime' => 'DESC'), 30, null); // 从这些文章中随机选择8篇 shuffle($categoryArticles); $randomSelectedArticles = array_slice($categoryArticles, 0, 8); {/php} {foreach $randomSelectedArticles as $article} <li> <div><a href=" {$article.Url} " title=" {$article.Title} " target="_blank"><img src=" {tupian($article)}" /></a></div> <p><a href=" {$article.Url} " title=" {$article.Title} " target="_blank"> {$article.Title} </a></p> </li> {/foreach}
11、php 常用代码 字段输出
echo '<pre>'; print_r($arr_test); echo '<pre>'; {php}echo $zbp->Config('gs_dana')->mn_duo5; {/php} {php}echo htmlspecialchars_decode($zbp->Config('gs_dana')->mn_duo5);{/php}
12、侧边栏热门和随机
<div class="widget widget_previous"> <h3>热门文章</h3> <ul> {php} global $zbp; // 获取热门文章 $articles = $zbp->GetArticleList( '*', array(array('=', 'log_Status', 0)), array('log_ViewNums' => 'DESC'), 6, null, false ); foreach ($articles as $article) { echo '<li>'; echo '<a href="' . $article->Url . '" title="' . htmlspecialchars($article->Title) . '" target="_blank">' . htmlspecialchars($article->Title) . '</a>'; echo '</li>'; } {/php} <div class="widget widget_previous"> <h3>随机文章</h3> <ul> {php} echo get_rand(6); // 调用函数获取随机6篇文章 {/php} </ul> </div> <div class="widget widget_catalog"> <h3>网站分类</h3> <ul> {php} echo get_all_categories(); {/php} </ul> </div> // zblogphp随机显示文章 // https://cloud.tencent.com/developer/article/1835012 // echo get_rand(6); // 调用函数获取随机6篇文章 if (!function_exists('get_rand')) { function get_rand($num){ global $zbp; $str = ''; $order = array('log_ViewNums' => 'ASC'); $where = array(array('=', 'log_Status', '0')); $array = $zbp->GetArticleList(array('*'), $where, $order, array(20), ''); // 确保传入的$num参数在合理范围内 $num = max(min($num, count($array)), 1); $arr = array_rand($array, $num); $arand = array(); for ($j = 0; $j < $num; $j++) { $arand[] = $array[$arr[$j]]; } foreach ($arand as $related) { $str .= "<li><a href=\"{$related->Url}\" title=\"{$related->Title}\" target=\"_blank\">{$related->Title}</a></li>"; } return $str; } }
13、模板框架数据保存
Main ,保存数据 字段
if (isset($_POST['ban_di'])) { // Define fields with their corresponding placeholders $fields = [ 'ban_link1' => '#1', 'ban_link2' => '#2', 'ban_link3' => '#3', 'ban_link4' => '#4', ]; // Process and save the form data foreach ($fields as $field => $placeholder) { $zbp->Config('gs_ai')->{"{$field}"} = isset($_POST[$field]) ? htmlspecialchars($_POST[$field], ENT_QUOTES) : ''; } // Save the configuration $zbp->SaveConfig('gs_ai'); // Show success message $zbp->ShowHint('good'); }
14、批量分类id main 和调用
'mn_st5' => '文章id', 'mn_cat5' => '分类id', 'mn_cout5' => '文章数量', <tr> <td><label for="title"><p>中间资讯</p></label></td> <td><p>文章id<input type="text" name="mn_st5" id="mn_st5" style="width:100%;" value="<?php echo $zbp->Config('xz_ok')->mn_st5;?>"/></p></td> <td><p>分类id<input type="text" name="mn_cat5" id="mn_cat5" style="width:100%;" value="<?php echo $zbp->Config('xz_ok')->mn_cat5;?>"/></p></td> <td><p>数量<input type="text" name="mn_cout5" id="mn_cout5" style="width:100%;" value="<?php echo $zbp->Config('xz_ok')->mn_cout5;?>"/></p></td> <td><p>自定义网站首页title标题</p></td> </tr> {php} $mn_st5 = $zbp->Config('xz_ok')->mn_st5; // 将字符串转换为数组,移除空值并确保每个值是整数 $mn_st5 = explode(',', $mn_st5); $mn_st5 = array_filter(array_map('intval', $mn_st5)); // 转换为整数并移除空值 $mn_cat5 = $zbp->Config('xz_ok')->mn_cat5; // 将字符串转换为数组,移除空值并确保每个值是整数 $mn_cat5 = explode(',', $mn_cat5); $mn_cat5 = array_filter(array_map('intval', $mn_cat5)); // 转换为整数并移除空值 $mn_cout5 = $zbp->Config('xz_ok')->mn_cout5; // 获取自定义文章和分类文章 $customPostr = get_id_cat_xin($mn_st5, $mn_cat5, $mn_cout5); {/php} {foreach $customPostr as $article} {/foreach}
15、微信 电话
{$article.Author.Email} {$article.Author.Intro} {$article.Author.HomePage} 手机号码:picfm 微信号:picxm 联系人:picnm 地址:pickm picvpm:所属区域 {$article.Metas.pic} {$article.Metas.picfm} 电话 {$article.Metas.picxm} 微信 {$article.Metas.picnm} 联系 {$article.Metas.pickm} 地址 {$article.Metas.picdpm} {$article.Metas.picvpm} {if $article.Metas.pic} {if $article.Metas.picvpm} {$article.Metas.picvpm}{else} xxx{/if}
16、分类分页代码
<div> {if $pagebar} <a href="{$category.Url}"><<</a> {foreach $pagebar.buttons as $k=>$v} {if $k == $pagebar.PageNow} <a href="{$v}">{$k}</a> {else} <a class="" href="{$v}">{$k}</a> {/if} {/foreach} <a href="{$category.Url}&page={$pagebar.PageAll}">>></a> {/if} </div>
发
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至123@#-@12-3.com举报,一经查实,本站将立刻删除。
共有 30 条评论