国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

55 行
1.6KB

  1. <?php
  2. /**
  3. * 站内新闻调用标签
  4. *
  5. * @version $Id:mynews.lib.php 1 9:29 2010年7月6日Z tianya $
  6. * @package DedeCMS.Taglib
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.com
  10. */
  11. /*>>dede>>
  12. <name>站内新闻</name>
  13. <type>全局标记</type>
  14. <for>V55,V56,V57</for>
  15. <description>站内新闻调用标签</description>
  16. <demo>
  17. {dede:mynews row='' titlelen=''/}
  18. </demo>
  19. <attributes>
  20. <iterm>row:调用站内新闻数</iterm>
  21. <iterm>titlelen:新闻标题长度</iterm>
  22. </attributes>
  23. >>dede>>*/
  24. function lib_mynews(&$ctag,&$refObj)
  25. {
  26. global $dsql,$envs;
  27. //属性处理
  28. $attlist="row|1,titlelen|24";
  29. FillAttsDefault($ctag->CAttribute->Items,$attlist);
  30. extract($ctag->CAttribute->Items, EXTR_SKIP);
  31. $innertext = trim($ctag->GetInnerText());
  32. if(empty($row)) $row=1;
  33. if(empty($titlelen)) $titlelen=30;
  34. if(empty($innertext)) $innertext = GetSysTemplets('mynews.htm');
  35. $idsql = '';
  36. if($envs['typeid'] > 0) $idsql = " WHERE typeid='".GetTopid($this->TypeID)."' ";
  37. $dsql->SetQuery("SELECT * FROM #@__mynews $idsql ORDER BY senddate DESC LIMIT 0,$row");
  38. $dsql->Execute();
  39. $ctp = new DedeTagParse();
  40. $ctp->SetNameSpace('field','[',']');
  41. $ctp->LoadSource($innertext);
  42. $revalue = '';
  43. while($row = $dsql->GetArray())
  44. {
  45. foreach($ctp->CTags as $tagid=>$ctag){
  46. @$ctp->Assign($tagid,$row[$ctag->GetName()]);
  47. }
  48. $revalue .= $ctp->GetResult();
  49. }
  50. return $revalue;
  51. }