Home CMS Tutorial DEDECMS How to call DEDE popular keywords

How to call DEDE popular keywords

Dec 25, 2019 am 10:27 AM
dede

How to call DEDE popular keywords

How to call DEDE popular keywords?

Popular tags in DEDE, DEDE homepage digg, DEDE random popular keyword calling methods, friends in need can refer to the following

Recommended learning: 梦Weavercms

DIGG

orderby=digg is sorted according to the number of DIGG

{dede:arclist row=5 titlelen=24 orderby=digg}
[field:textlink/] [field:digg/]<br/>
{/dede:arclist}
Copy after login

The specific detailed code is as follows

<div class="dignews margintop">
<div class="digtitle"><span></span>
<ul id="digtitle">
<li><a href="###">热门</a> </li>
<li><a href="###">推荐</a> </li>
<li><a href="###">关注</a> </li>
</ul>
</div>
<dl id="diglist"><dt>正在载入,请稍后... <!--DIG菜单:热门--></dt><dd><!--DIG循环体开始-->{dede:arclist row=5 titlelen=24 orderby=digg} 
<div class="digbox" id="digboxa">
<div class="diglink" id="digg[field:id/]"><span>[field:digg/]</span> <a class="digvisited" href="javascript:Digg(&#39;digg&#39;,[field:id/]);"><!--顶一下--></a></div>
<div class="title">[field:textlink/]<span>[field:pubdate function=strftime(&#39;%m-%d&#39;,@me)/]</span> </div>
<div class="preview">[field:info/]... </div>
</div>
{/dede:arclist} <!--DIG循环体结束--><!--DIG菜单:推荐--></dd><dd><!--DIG循环体开始-->{dede:arclist row=5 titlelen=24 orderby=digg att=5} 
<div class="digbox" id="digboxb">  
<div class="diglink" id="digg[field:id/]"><span>[field:digg/]</span> <a class="digvisited" href="javascript:Digg(&#39;digg&#39;,[field:id/]);"><!--顶一下--></a></div>
<div class="title">[field:textlink/]<span>[field:pubdate function=strftime(&#39;%m-%d&#39;,@me)/]</span> </div>
<div class="preview">[field:info/]... </div>
</div>
{/dede:arclist} <!--DIG循环体结束--><!--DIG菜单:关注--></dd><dd><!--DIG循环体开始-->{dede:arclist row=5 titlelen=24 orderby=click}
<div class="digbox" id="digboxc">
<div class="diglink" id="digg[field:id/]"><span>[field:digg/]</span> <a class="digvisited" href="javascript:Digg(&#39;digg&#39;,[field:id/]);"><!--顶一下--></a></div>
<div class="title">[field:textlink/]<span>[field:pubdate function=strftime(&#39;%m-%d&#39;,@me)/]</span> </div>
<div class="preview">[field:info/]... </div>
</div>
{/dede:arclist} <!--DIG循环体结束--></dd></dl></div>
</div>  
<!--左侧栏结束--><script language="javascript" type="text/javascript"> 
<!--
//DIGG资讯无刷新切换
pigzmo("digtitle","diglist",3,3000);
-->
</script><!--中栏-->
Copy after login

DEDE5 With the DIGG function, you can see that the number of "likes" has been increased by 1 after you like it, but if you refresh the page, you will find that the number of "likes" has been restored.

This is because the article has been liked and static HTML has been generated and fixed for display, unless the article is updated in the background next time.

Then I made the following modifications, that is, when the current article When it is liked, the article is updated at the same time so that the number of "likes" in its static HTML is the latest real number.

The modification method is very simple, as follows:

Open the digg.php file in the root directory of DEDE and insert the following three lines of code in line 26

include_once(dirname(__FILE__)."/include/inc_archives_view.php");
$arc = new Archives($aid);
$reurl = $arc->MakeHtml();
Copy after login

The home page can be topped How to automatically refresh at once:

Open the diggindex.php file. .

Find

header("Expires:0");
header("Content-Type: text/html; charset=gb2312");
Copy after login

Add

below and the code is as follows:

if($action == indexdigg ){
echo &#39;<span>&#39;.$row[&#39;digg&#39;].&#39;</span>&#39;;
echo "<a class=\"digvisited\" href=\"javascript:Digg(\"digg\",".$aid.");\"></a>";
exit();
}
Copy after login

Home page template add

The code is as follows:

<!-- Digg 参数 -->
<script language="javascript" src="{dede:global name=&#39;cfg_cmspath&#39;/}/include/dedeajax2.js"></script>
<script language="javascript"> 
function Digg(divId,aid){
var taget_obj = document.getElementById(divId+&#39;&#39;+aid);
var myajax = new DedeAjax(taget_obj,false,false,"","","");
myajax.SendGet2("/diggindex.php?action=indexdigg&aid="+aid);
DedeXHTTP = null;
}
</script>
Copy after login

Example:

<div class="right"><!-- Digg 参数 -->
<script language="javascript" src="{dede:global name=&#39;cfg_cmspath&#39;/}/include/dedeajax2.js"></script>
<script language="javascript">
function Digg(divId,aid){
var taget_obj = document.getElementById(divId+&#39;&#39;+aid);
var myajax = new DedeAjax(taget_obj,false,false,"","","");
myajax.SendGet2("/diggindex.php?action=indexdigg&aid="+aid);
DedeXHTTP = null;
}
</script>
<div class="digtitle">DIGG排行</div>
<div class="diglist">
{dede:arclist row=9 titlelen=24 infolen=&#39;29&#39; orderby=digg}
<dd>
<div class="diglink" id="digg[field:id/]"><span>[field:digg/]</span> <a class="digvisited" href="javascript:Digg(&#39;digg&#39;,[field:id/]);"><!--顶一下--></a></div> 
<h3>[field:textlink/]</h3> 
[field:info/]...
</dd>
{/dede:arclist}
</div>
</div>
Copy after login

Template code:

{dede:tag row=&#39;10&#39; sort=&#39;month&#39; } <a class="tag" href="[field:link/]">[field:tagname/] </a>{/dede:tag} <script language="javascript">
<!--
var tag_a=document.getElementsByTagName("a");
for( i in tag_a){
var offset=6;
var num=4;
if(tag_a[i].className=="tag"){
var rnd=Math.ceil((num+offset)*Math.random());
if(rnd>offset){
tag_a[i].className="tag"+(rnd-offset);
}
}
}
//-->
</script>
Copy after login

CSS code:

.tag1 { color:#339900;font-weight:bold;}
.tag2 { color:#e65730;}
.tag3 { color:#00b9da;}
.tag4 { color:#FE3981;font-weight:bold;font-size:14px;}
Copy after login
Copy after login

How to change tags:

The popular tags of the month are called by default. If You can think of something else:

Latest tag{dede:tag row='30' sort='new'}[field:highlight/] ([field:result/]) {/dede:tag}

Popular tags of the month{dede:tag row='30' sort='month'}[field:tagname/]([field:result/]) {/dede:tag}

Random tag{dede:tag row='60' sort='rand'}[field:highlight/]([field:result/]) {/dede:tag}

The code of the web page part is as follows:

<div>
<h2><span>热门标签 <img alt="" src=http://qlzhan.com/a/DEDEcms/20091005/"images_ex/image_v1/ico_arrow_black.gif" /></span></h2>
<ul>{dede:loop table=&#39;dede_search_keywords&#39; sort=&#39;keyword&#39; row=&#39;40&#39; if=&#39;&#39;}
<li><a class="tag" href="plus/search.php?keyword=[field:keyword/]">[field:keyword/]</a> {/dede:loop} </li>
</ul>
</div>
<script language="javascript">
<!--
var tag_a=document.getElementsByTagName("a");
for( i in tag_a){
var offset=6;
var num=4;
if(tag_a[i].className=="tag"){ 
var rnd=Math.ceil((num+offset)*Math.random());
if(rnd>offset){ 
tag_a[i].className="tag"+(rnd-offset);
}
}
}
//-->
</script>
<div></div>
Copy after login

The code of the CSS part is as follows:

.tag1 { color:#339900;font-weight:bold;}
.tag2 { color:#e65730;}
.tag3 { color:#00b9da;}
.tag4 { color:#FE3981;font-weight:bold;font-size:14px;}
Copy after login
Copy after login

Instructions for use: ◆There are 4 color changes in this color keyword code, if you want to add more To change the color, you only need to modify var num=4; and add .tag to the css part. For example: var num=5; add .tag5{ color:#00b9da;} to the css. Of course, you can also modify the corresponding css to change the font color. , size, font...etc., feel free to play with it!

The above is the detailed content of How to call DEDE popular keywords. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)