{dede:field name='id' runphp='yes'}$tsql = new DedeSql(false);$typelink2 = '';$tsql->SetQuery("Select i.typedir,i.typename From #@__arctype t left join #@__arctype i on i.id=t.reid where t.id='@me'");$tsql->Execute('t');while($row = $tsql->GetArray('t',MYSQL_ASSOC)){$typelink2 .= $row['typename'];}@me=$typelink2;{/dede:field}

如果你觉得在模板中嵌入这么长的php代码很不美观的话,也可以将其写成一个函数放入include/extend.func.php文件中,例如:

function GetParentCategoryNameByID($CurrentID){

$tsql = new DedeSql(false);

$typelink2 = '';

$tsql->SetQuery("Select i.typedir,i.typename From #@__arctype t left join #@__arctype i on i.id=t.reid where t.id='$CurrentID'");

$tsql->Execute('t');

while($row = $tsql->GetArray('t',MYSQL_ASSOC))

{

$typelink2 .= $row['typename'];

}

return $typelink2;

}

调用方法:{dede:field name='id' function='GetParentCategoryNameByID(@me)' /}

相关文章:

  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2021-06-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2021-11-08
  • 2021-10-28
相关资源
相似解决方案