中国专业的PHP网站内容管理系统-织梦内容管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.6KB

  1. <?php if(!defined('DEDEINC')) exit('Request Error!');
  2. /**
  3. * 按排序位置的获取单个栏目的链接信息
  4. *
  5. * @version $Id: autochannel.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:autochannel partsort='' typeid=’’}{/dede:autochannel}
  18. </demo>
  19. <attributes>
  20. <iterm>partsort:栏目所在的排序位置</iterm>
  21. <iterm>typeid:获取单个栏目的顶级栏目</iterm>
  22. </attributes>
  23. >>dede>>*/
  24. function lib_autochannel(&$ctag,&$refObj)
  25. {
  26. global $dsql;
  27. $attlist='partsort|0,typeid=-1';
  28. FillAttsDefault($ctag->CAttribute->Items,$attlist);
  29. extract($ctag->CAttribute->Items, EXTR_SKIP);
  30. $innertext = trim($ctag->GetInnerText());
  31. $topid = $typeid;
  32. $sortid = $partsort;
  33. if($topid=='-1' || $topid=='')
  34. {
  35. $topid = ( isset($refObj->TypeLink->TypeInfos['id']) ? $refObj->TypeLink->TypeInfos['id'] : 0);
  36. }
  37. if(empty($sortid)) $sortid = 1;
  38. $getstart = $sortid - 1;
  39. $row = $dsql->GetOne("SELECT id,typename FROM `#@__arctype` WHERE reid='{$topid}' AND
  40. ispart<2 AND ishidden<>'1' ORDER BY sortrank asc limit $getstart,1");
  41. if(!is_array($row) ) return '';
  42. else $typeid = $row['id'];
  43. if(trim($innertext)=='') $innertext = GetSysTemplets('part_autochannel.htm');
  44. $row = $dsql->GetOne("SELECT id,typedir,isdefault,defaultname,ispart,namerule2,typename,moresite,siteurl,sitepath
  45. FROM `#@__arctype` WHERE id='$typeid' ");
  46. if(!is_array($row)) return '';
  47. $dtp = new DedeTagParse();
  48. $dtp->SetNameSpace('field','[',']');
  49. $dtp->LoadSource($innertext);
  50. if(!is_array($dtp->CTags))
  51. {
  52. unset($dtp);
  53. return '';
  54. }
  55. else
  56. {
  57. $row['typelink'] = GetTypeUrl($row['id'],MfTypedir($row['typedir']),$row['isdefault'],
  58. $row['defaultname'],$row['ispart'],$row['namerule2'],$row['siteurl'],$row['sitepath']);
  59. foreach($dtp->CTags as $tagid=>$ctag)
  60. {
  61. if(isset($row[$ctag->GetName()])) $dtp->Assign($tagid,$row[$ctag->GetName()]);
  62. }
  63. $revalue = $dtp->GetResult();
  64. unset($dtp);
  65. return $revalue;
  66. }
  67. }