In Bezug auf die Verwendung von Klicks auf phpcms V9 sollte es viele direkte Aufrufe zu den im Internet gesuchten Codes geben. Einige Leute, die sich eingehend informieren und weiterentwickeln möchten, sind jedoch noch verwirrter, nachdem sie die Codes gesehen haben Nachdem ich es ein paar Tage lang gelesen habe, werde ich es aufschreiben und hier teilen. Lassen Sie uns zunächst das Grundwissen verstehen
pc_base::load_model(‘*<span style="color: #000000;">_model’) 加载数据库模型 pc_base::load_sys_class(‘classname’) 实例化系统类 pc_base::load_app_class(‘classname’,’admin’) 实例化模块类 pc_base::load_sys_func (‘funcfile’) 调用系统函数库</span>
<span style="color: #008080;">1</span> {pc:content action=<span style="color: #800000;">"</span><span style="color: #800000;">lists</span><span style="color: #800000;">"</span> catid=<span style="color: #800000;">"</span><span style="color: #800000;">$catid</span><span style="color: #800000;">"</span> num=<span style="color: #800000;">"</span><span style="color: #800000;">25</span><span style="color: #800000;">"</span> order=<span style="color: #800000;">"</span><span style="color: #800000;">id DESC</span><span style="color: #800000;">"</span> page=<span style="color: #800000;">"</span><span style="color: #800000;">$page</span><span style="color: #800000;">"</span> moreinfo=<span style="color: #800000;">"</span><span style="color: #800000;">1</span><span style="color: #800000;">"</span><span style="color: #000000;">} </span><span style="color: #008080;">2</span> <span style="color: #000000;">{loop $data $r} </span><span style="color: #008080;">3</span> {php $db = pc_base::load_model(<span style="color: #800000;">'</span><span style="color: #800000;">hits_model</span><span style="color: #800000;">'</span>); $_r = $db->get_one(array(<span style="color: #800000;">'</span><span style="color: #800000;">hitsid</span><span style="color: #800000;">'</span>=><span style="color: #800000;">'</span><span style="color: #800000;">c-</span><span style="color: #800000;">'</span>.$modelid.<span style="color: #800000;">'</span><span style="color: #800000;">-</span><span style="color: #800000;">'</span>.$r[id])); $views =<span style="color: #000000;"> $_r[views]; } </span><span style="color: #008080;">4</span> {php $comment_tag = pc_base::load_app_class(<span style="color: #800000;">"</span><span style="color: #800000;">comment_tag</span><span style="color: #800000;">"</span>, <span style="color: #800000;">"</span><span style="color: #800000;">comment</span><span style="color: #800000;">"</span>); $comment_total = $comment_tag->count(array(<span style="color: #800000;">'</span><span style="color: #800000;">commentid</span><span style="color: #800000;">'</span>=><span style="color: #800000;">'</span><span style="color: #800000;">content_</span><span style="color: #800000;">'</span>.$catid.<span style="color: #800000;">'</span><span style="color: #800000;">-</span><span style="color: #800000;">'</span>.$r[id].<span style="color: #800000;">'</span><span style="color: #800000;">-</span><span style="color: #800000;">'</span><span style="color: #000000;">.$modelid));} </span><span style="color: #008080;">5</span> <li><span <span style="color: #0000ff;">class</span>=<span style="color: #800000;">"</span><span style="color: #800000;">rt</span><span style="color: #800000;">"</span>>{date(<span style="color: #800000;">'</span><span style="color: #800000;">Y-m-d H:i:s</span><span style="color: #800000;">'</span>,$r[inputtime])}</span>·<a href=<span style="color: #800000;">"</span><span style="color: #800000;">{$r[url]}</span><span style="color: #800000;">"</span> target=<span style="color: #800000;">"</span><span style="color: #800000;">_blank</span><span style="color: #800000;">"</span>{title_style($r[style])}>{$r[title]}</a> 点击:{$views} 评论数:{<span style="color: #0000ff;">if</span> $comment_total}{$comment_total}{<span style="color: #0000ff;">else</span>}<span style="color: #800080;">0</span>{/<span style="color: #0000ff;">if</span>}</li>{/<span style="color: #000000;">loop} </span><span style="color: #008080;">6</span> <span style="color: #000000;">{$pages} </span><span style="color: #008080;">7</span> {/pc}
$db = pc_base::load_model('hits_model')
<span style="color: #0000ff;">class</span><span style="color: #000000;"> hits_model extends model { </span><span style="color: #0000ff;">public</span> $table_name = <span style="color: #800000;">''</span><span style="color: #000000;">; </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> function __construct() { $</span><span style="color: #0000ff;">this</span>->db_config = pc_base::load_config(<span style="color: #800000;">'</span><span style="color: #800000;">database</span><span style="color: #800000;">'</span><span style="color: #000000;">); $</span><span style="color: #0000ff;">this</span>->db_setting = <span style="color: #800000;">'</span><span style="color: #800000;">default</span><span style="color: #800000;">'</span><span style="color: #000000;">; $</span><span style="color: #0000ff;">this</span>->table_name = <span style="color: #800000;">'</span><span style="color: #800000;">hits</span><span style="color: #800000;">'</span><span style="color: #000000;">; parent::__construct(); } }</span>
final <span style="color: #0000ff;">public</span> function get_one($<span style="color: #0000ff;">where</span> = <span style="color: #800000;">''</span>, $data = <span style="color: #800000;">'</span><span style="color: #800000;">*</span><span style="color: #800000;">'</span>, $order = <span style="color: #800000;">''</span>, $group = <span style="color: #800000;">''</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">if</span> (is_array($<span style="color: #0000ff;">where</span>)) $<span style="color: #0000ff;">where</span> = $<span style="color: #0000ff;">this</span>->sqls($<span style="color: #0000ff;">where</span><span style="color: #000000;">); </span><span style="color: #0000ff;">return</span> $<span style="color: #0000ff;">this</span>->db->get_one($data, $<span style="color: #0000ff;">this</span>->table_name, $<span style="color: #0000ff;">where</span><span style="color: #000000;">, $order, $group); }</span>
'hitsid'=>'c-'.$modelid.'-'.$r[id])) Das in der Methode übergebene Array ist der Wert des Feldes in der Datentabelle v9_hits. Die Struktur der Treffertabelle ist wie folgt
$_r ist derzeit ein Datenelement in der Tabelle. Die Feldansichten in der Datentabelle geben die Anzahl der Klicks auf diesen Artikel an. Verwenden Sie also $_r[views], um die Anzahl der Klicks zu ermitteln. ! !
Hinweis: In den Hitsid-Felddaten c-1-2 stellt 1 die aktuelle Modell-ID und 2 die ID des aktuellen Artikels dar