Everyone knows that this function can aggregate related articles. Since it is displayed in the middle of the text, it can not only improve the user experience, but also achieve optimization effects.
At present, I found that some high-authority websites are using this function, so I studied for several hours and wrote this tutorial!
It’s not just a little help for website optimization, I believe all the website optimization experts know it!
This feature was also suggested to me by a website optimization expert. I hope it will be helpful to all webmasters!
Whether you are a collection site, a regular article site, an information site, a product, novel or movie site, this function is suitable. Of course, the premise is that your website is an empire cms!
Effect preview:

Insert a related article in the middle of the article, and you can set the number of articles
No complicated plug-ins are required, just follow the tutorial!
If not, you can contact me to help install it.
Tutorial steps:
Step 1: Install the code
Open the file /e/class/userfun.php
Put the following PHP function code into the second line
PHP function code:
隐藏内容:付费阅读
function content_more_page($id,$stb,$content,$sign,$num=8,$biao = 'news'){
global $empire,$dbtbpre;
$is = $empire->fetch1("SELECT keyid FROM `phome_ecms_{$biao}_data_{$stb}` WHERE `id` = {$id} ");
if(!empty($is['keyid'])){
$is['keyid'] = rtrim($is['keyid'],",");
$arr_keyid = explode(",",$is['keyid']);
if(count($arr_keyid) > $num){
$rand_keyid = array_rand($arr_keyid,$num);
foreach($rand_keyid as $v){
$more_id.= $arr_keyid[$v].",";
}
$more_id = rtrim($more_id,",");
}else{
$more_id = $is['keyid'];
}
$found_news = $empire->query("SELECT title,titleurl FROM `phome_ecms_{$biao}` WHERE id in({$more_id}) ORDER BY `id` DESC ");
while($j=$empire->fetch($found_news)) //循环获取查询记录
{
$li.="<li class='more_li'><a href='{$j['titleurl']}' title='{$j['title']}'>{$j['title']}</a></li>";
}
$more_this_content = '<ul id="more_ul"><strong>也许对您有帮助</strong>'.$li."</ul>";
return content_center($content,$more_this_content,$sign);
}else{
return $content;
}
}
function content_center($content,$other,$sign){
$y = $content;
$n = floor(substr_count($content,$sign)/2);
for ($i=1;$i<=$n;$i++){
$pos = strpos($content,$sign);
$content = substr($content,$pos+1);
$pos_val=$pos+$pos_val+1;
}
$count = $pos_val-1;
return substr($y,0,$count).$other.substr($y,$count);
}
PHP code for the second version:
Fixed array_rand function call asking the wrong question.
Added newstime judgment, suitable for websites that regularly publish articles!
隐藏内容:付费阅读
<?php
//---------------------------用户自定义标签函数文件
function content_more_page($id,$stb,$content,$sign,$num=8,$biao = 'news'){
global $empire,$dbtbpre;
$is = $empire->fetch1("SELECT keyid FROM `phome_ecms_{$biao}_data_{$stb}` WHERE `id` = {$id} ");
if(!empty($is['keyid'])){
$is['keyid'] = rtrim($is['keyid'],",");
$arr_keyid = explode(",",$is['keyid']);
if(!empty($arr_keyid)){
$num = count($arr_keyid) >= $num ? count($arr_keyid) : $num;
$rand_keyid = array_rand($arr_keyid,$num);
foreach($rand_keyid as $v){
$more_id.= $arr_keyid[$v].",";
}
$more_id = rtrim($more_id,",");
}else{
return $content;
}
$found_news = $empire->query("SELECT title,titleurl FROM `phome_ecms_{$biao}` WHERE id in ({$more_id}) and newstime <= ".time()." ORDER BY `id` DESC ");
while($j=$empire->fetch($found_news)) //循环获取查询记录
{
$shows = !empty($j['title'])?true:false;
$li.="<li class='more_li'><a href='{$j['titleurl']}' title='{$j['title']}'>{$j['title']}</a></li>";
}
$more_this_content = '<ul id="more_ul"><strong>也许对您有帮助</strong>'.$li."</ul>";
if($shows){
return content_center($content,$more_this_content,$sign);
}else{
return $content;
}
}else{
return $content;
}
}
function content_center($content,$other,$sign){
$y = $content;
$n = floor(substr_count($content,$sign)/2);
for ($i=1;$i<=$n;$i++){
$pos = strpos($content,$sign);
$content = substr($content,$pos+1);
$pos_val=$pos+$pos_val+1;
}
$count = $pos_val-1;
return substr($y,0,$count).$other.substr($y,$count);
}
Step 2: Replace the call template in the article template
The original calling method is: [!--newstext--]
Now let's change it to this:
隐藏内容:付费阅读
<?=content_more_page($navinfor['id'],$navinfor['stb'],$navinfor['newstext'],'</p>','news')?>
The first parameter is the article id
The second parameter is the schedule id corresponding to the content.
The third one is news content
The fourth is to add it after the label (generally no need to modify)
What is the fourth table? It is usually the news table.
Step 3: Enable the empire’s aggregation function
The activation method is as shown in the figure:
Required conditions: Each article must be set with keywords, and each keyword is separated by English, because only in this way can the aggregation function of Empire be successfully aggregated.
If your imperial website does not have keywords set, but the number of articles is very large, then you can contact me to help you solve it.
Solution: Use the word segmentation API to segment the title (paid separately)