0712-2888027 189-8648-0214
微信公眾號(hào)

孝感風(fēng)信網(wǎng)絡(luò)科技有限公司微信公眾號(hào)

當(dāng)前位置:主頁(yè) > 技術(shù)支持 > PHPCMS > phpcms在下載內(nèi)容頁(yè)直接下載文件并帶有下載次數(shù)

phpcms在下載內(nèi)容頁(yè)直接下載文件并帶有下載次數(shù)

時(shí)間:2024-09-20來(lái)源:風(fēng)信官網(wǎng) 點(diǎn)擊: 865次

方法一:

一、識(shí)別
識(shí)別出系統(tǒng)默認(rèn)模板方案的兩個(gè)文件:
default/phpcms/show_down.html
default/phpcms/down.html

二、操作
下載模型里面使用“下載列表”字段就可以,禁止掉“下載地址”字段。

1、修改show_down.html模板
<h3>下載地址</h3>
<div id="down_address">
{$downurl}
{$downurls}
</div>

變成:

<h3>下載地址</h3>
<script type="text/javascript">
$(function(){
$.get('{$downurls}',function(data){
$('#down_address').html(data);
});
});
</script>
<div id="down_address"></div>

或者
<h3>下載地址</h3>
<script type="text/javascript">
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("down_address").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","{$downurls}",true);
xmlhttp.send();
</script>
<div id="down_address"></div>

說(shuō)明:沒(méi)有引用JQuery時(shí)就用這種方式。

2、修改down.html模板
注釋掉整模板內(nèi)容,在文件末尾并加入一段代碼。
<?php
/*
注釋模板內(nèi)容而不刪除,目的就是盡量保持系統(tǒng)原有的內(nèi)容,以便日后使用或修改。
*/
?>
<a href="http://lanfeng898.blog.163.com/blog/{$downurl}">{$head[title]}</a>
//{$head[title]}是標(biāo)題名,可以自定義下載名稱,如:高速下載、快速下載等等。

方法二:

在down.html頁(yè)面它的<meta>里面改成或者添加
<meta http-equiv="refresh" content="0;URL={$downurl}" />

在<body>里面加入

<script type="text/javascript">
//<!--
function isIFrameSelf(){try{if(window.top ==window){return false;}else{return true;}}catch(e){return true;}}
function toHome(){ if(!isIFrameSelf()){ window.location.href="/index.php";}window.close();}
window.setTimeout("toHome()",5000);
//-->
</script>

讓其在5秒內(nèi)關(guān)閉窗口

欄目列表
推薦內(nèi)容
熱點(diǎn)內(nèi)容
展開(kāi)