Hongmu Notes
Home Program Notes Imperial cms commonly used calling code SEO direction
Program Notes Empire cms

Imperial cms commonly used calling code SEO direction

Imperial cms commonly used calling code SEO direction

It is very troublesome to find codes every time for website optimization, so I will give some backup here, including some customized functions. In fact, most of them are PHP codes.

Category 1: Highly efficient random calling code


<?php
$randnum=32; //随机数量
$randids='';
$randdh='';
for($i=1;$i<=$randnum;$i++)
{
$randids.=$randdh.rand(1,100); //1为最小ID,100000为最大ID
$randdh=',';
}
?> [e:loop={1,32,0,0,"id in ($randids)"}]      
<li>
<a href="<?=$bqsr['titleurl']?>" title="<?=$bqr['title']?>"><?=$bqr['title']?></a>
</li>                  
[/e:loop]

Randomly efficient evolved version:

This version of the code is mainly to facilitate the retrieval of random articles in the specified column. In order to facilitate template editing, it is not encapsulated into a function.


<?php
$file_cache = ECMS_PATH."news.json";
//缓存整个news表的数据
if(!file_exists($file_cache)){
    //查询分类
    $hm_class=$empire->query("select classid from {$dbtbpre}enewsclass");   
    while($hm_r=$empire->fetch($hm_class))
    {
        //查询分类下面的所有id
        $hm_news=$empire->query("SELECT id FROM `{$dbtbpre}ecms_news` WHERE `classid` = {$hm_r[classid]}");   
        while($hm_nr=$empire->fetch($hm_news))
        {
            $news_data[$hm_r['classid']][] = $hm_nr[id];
        }
    }
    file_put_contents($file_cache,json_encode($news_data));
}
//获取缓存数据表
$file_arrs = json_decode(file_get_contents($file_cache),true);
//根据数据表获取id,每个栏目随机分配文章id
foreach($file_arrs as $k=>$v){
    $num = count($v)-1;
    //增加变量
    for ($rani=1; $rani<=30; $rani++){
        $rand_id.= $v[mt_rand(0,$num)].",";    
    }
    $rand_id = rtrim($rand_id,",");
    $rand_data[] = $rand_id;
    $rand_id = "";
    $rani=1;
}
?>

Calling method:


<?php
$classid = $rand_data[$class_r[$GLOBALS[navclassid]][classid]-1];
?>
[ecmsinfo]0,20,32,0,3,14,0,"id in ($classid)"[/ecmsinfo]

Highly efficient random tag calling


<?php
$num=$empire->num("select tagid from {$dbtbpre}enewstags");
$randnum=100; 
$randids=''; 
$randdh=''; 
for($i=1;$i<=$randnum;$i++) 
{ 
$randids.=$randdh.rand(1,$num); 
$randdh=',';
} 
?>
[e:loop={"select tagname,tagid from phome_enewstags where tagid in ($randids)  limit $randnum",32,24,0}]
<a target="_blank" href="/tag/<?=$bqr['tagid']?>/" title="<?=$bqr['tagname']?>"><?=$bqr['tagname']?></a> | 
[/e:loop]

Randomly call tags. In fact, this can be modified to randomly call the information of all tables. You can modify it yourself.

 

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Empire CMS database statement & SQL statement format

Empire CMS database statement & SQL statement format Program Notes Empire cms

Introduction to Imperial CMS extended SQL program writing, basic examples of Imperial CMS database statements & SQL statement formats: Note: The following examples are based on placing PHP files in the system root directory. Example 1: Connect to MYSQL program. (a.php)<?php require('e/class/connect.php'); //Introduce database configuration files and public function files requ…
👁 351
Empire CMS obtains the system COOKIE variable function getcvar()

Empire CMS obtains the system COOKIE variable function getcvar() Program Notes Empire cms

Get the system COOKIE variable function syntax: getcvar($var,$ecms) Description: $var: is the variable name $ecms: 0 is to set the foreground COOKIE variable, 1 is to set the background COOKIE variable. This parameter can be omitted and defaults to 0. Usage example: getcvar('mlusername'), get the user name of the front-end login member getcvar('loginu...
👁 295
Empire CMS smart label call field collection

Empire CMS smart label call field collection Program Notes Empire cms

Collect and classify all fields that support smart tag calls into Empire CMS smart tags: [e:loop={column ID/topic ID, number of items displayed, operation type, only display pictures with titles, additional SQL conditions, display sorting}] Template code content [/e:loop] Calling time: <?=date('m-d',$bqr[newstime])?> <?=dat…
👁 3749

Recommended reading

(Adaptive Mobile Version) Traditional Chinese Medicine Clinic Website Template – 1000

(Adaptive Mobile Version) Traditional Chinese Medicine Clinic Website Template – 1000 Practical Collection pbootcms Template

A Chinese medicine shop and traditional Chinese medicine PbootCMS website template, supporting PC and WAP. The design style is classical and traditional, suitable for traditional Chinese medicine halls and traditional Chinese medicine stores to display services, physician teams and traditional Chinese medicine products. It helps traditional Chinese medicine institutions establish a professional image online and attract patients. Template display Installation instructions Website backend:/admin.php Account: admin Password: admin Unzip password: www.4s5.cn Related articles…
👁 50
How to enable error reporting in php?

How to enable error reporting in php? Summary of pitfalls

Simple and efficient method. Add the code directly. <?php error_reporting(E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); ?> Just add the following code at the very top of the erroring PHP file, for the current script only...
👁 84
What does loose or watery stool mean in Traditional Chinese Medicine?

What does loose or watery stool mean in Traditional Chinese Medicine? Hobbies Traditional Chinese Medicine Terminology

In traditional Chinese medicine (TCM) practice, loose stools typically refer to stools that are more watery than usual or even contain liquid discharge; this condition is also known as diarrhea. It often occurs in cases associated with TCM pathological mechanisms such as Spleen and Stomach Deficiency-Cold, dyspepsia, or excessive dampness. Spleen and Stomach Deficiency-Cold refers to a deficiency of Yang energy in the body, which leads to impaired function of the digestive system and consequently affects the formation of stools. Dyspepsia denotes a weakened digestive and absorptive capacity of the gastrointestinal tract, resulting in incomplete digestion and absorption of food, which in turn affects stool consistency...
👁 162
(Adaptive Mobile App) Single-Page Website Template – App Implementation Page 1001

(Adaptive Mobile App) Single-Page Website Template – App Implementation Page 1001 Practical Collection pbootcms Template

A single-page landing page template for PbootCMS websites, compatible with both PC and WAP devices. Featuring a modern, tech-driven design with a strong marketing focus, this template is ideal for high-conversion landing pages such as app promotions or software download pages. It enables app developers to quickly create promotional pages and attract users to download their apps. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www....
👁 33