dede不使用js调用非DEDE数据 如论坛等其他cms数据_DedeCms教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!
对于织梦dedecms主站和论坛分隔2地的,大家一般首页调用论坛都是JS来搞是吧,下面推荐一个好方法实现html调用,对搜索引擎友好。
 
论坛以PW举例:
一般实现方法:
  1. <script src="http://bbs.myiphones.com.cn/new.php?action=article&digest=1&postdate=0&author=0&fname=0&hits=0&replies=0&pre=0&num=7&length=40&order=2"></script> 
对搜索引擎很不友好,不能抓取,而且万一论坛挂了,搞的主站也很慢。
修正方法:
  1. {dede:huataixiangqi runphp=’yes’}  
  2. @me = file_get_contents(‘http://bbs.*****.com.cn/new.php?action=article&pre=1&num=10&length=50&order=2&fidin=15&digest=0&postdate=0&author=0&fname=0&hits=0&replies=0′);  
  3. {/dede:huataixiangqi} 
ok了,是不是很简单啊。
 
注:此方法最好只用在首页,如果在内容也也这样搞,可能生成html很慢 
修改论坛new.php:
本来读取论坛的数据是js数据:
  1. document.write("<li> <a href=’http://bbs.***.com.cn/read.php?tid=57787′ target=’_blank’>iPhone玩家不愿外传的smart壁纸</a> <br>");  
  2. document.write("<li> <a href=’http://bbs.***.com.cn/read.php?tid=56837′ target=’_blank’>iphone2.0以上固件下载,这些资源都是对大 ..</a> <br>");  
  3. document.write("<li> <a href=’http://bbs.***.com.cn/read.php?tid=54915′ target=’_blank’>白苹果问题解决办法以及原因简单分析 方法 ..</a> <br>");  
  4. document.write("<li> <a href=’http://bbs.***.com.cn/read.php?tid=54502′ target=’_blank’>各平台建立iphone 开发环境的方法</a> <br>");  
  5. document.write("<li> <a href=’http://bbs.***.com.cn/read.php?tid=54058′ target=’_blank’>如何解决删除SummberBoard后变白苹果的问题</a> <br>");  
  6. document.write("<li> <a href=’http://bbs.***.com.cn/read.php?tid=53664′ target=’_blank’>iphone棋牌类游戏汇总!爱牌的疯友别错过 ..</a> <br>");  
  7. document.write("<li> <a href=’http://bbs.***.com.cn/read.php?tid=53623′ target=’_blank’>iPhone内置铃声全下载</a> <br>"); 
现在不需要js数据,要的是html数据,所以大家需要把论坛new.php里的输出语句中的document.write去掉。
 
其他程序举例:
  1. {dede:book runphp=’yes’}  
  2. @me = file_get_contents(‘http://book.myiphones.com.cn/freelist/new.html’);  
  3. {/dede:book} 
拿来就用,数据读取端格式要对就OK

查看更多 DedeCms教程  织梦模板  织梦DedeCms视频教程  织梦dedecms专题

来源:模板无忧//所属分类:DedeCms教程/更新时间:2020-05-09
相关DedeCms教程