企業(yè)官網(wǎng)首頁調用公司介紹內容,一般分三塊內容。
調用宣傳視頻、調用一張圖片,調用文字介紹內容。

直接調用公司介紹欄目的內容是最佳方案,避免重復修改,但要求只調用文字,過濾掉圖片、視頻、等內容,為了美觀,還要過濾掉空行,保留換行。
第一步:
打開 config/custom.php
添加
<?php
/**
* 開發(fā)者自定義函數(shù)文件
*/
function dr_reserve_text($str) {
if (is_array($str) || !$str) {
return '';
}
$str = preg_replace('~<img(.*?)>~s','',$str); //過濾圖片
$str = preg_replace('~<video(.*?)>~s','',$str); //過濾視頻
$str = str_replace("div","p",$str); //div轉p
$str = str_replace("<p><br></p>","",$str); //刪除空行
return trim($str);
}首頁調用代碼:
假設公司簡介欄目ID為2
{dr_strcut(dr_reserve_text(dr_share_cat_value(2, 'content')), 600)}調用并截取600個字。。
效果如上圖所示:
調用內容中第1個視頻
{php $videos = dr_get_content_url(dr_share_cat_value(2, 'content'), 'src', 'mp4', 1);}
<video width="100%" height="auto" controls style="max-height: 500px">
<source src="{$videos[0]}" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
您的瀏覽器不支持 video 標簽。
</video>{php $imgs = dr_get_content_img(dr_share_cat_value(2, 'content'), 1);}
<img src="{$imgs[0]}">