欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

dedecms php 中使用变量 在 模板文件htm中输出 解析

shiping1 的头像

$GLOBALS 在任意地方都可以取得到



1)第一种方法

dedecms aaa.php 中使用变量 在 模板文件 aaa.htm中 输出的方法

在 php中

$backStr = "AAA";

$GLOBALS['backStr']=$backStr;

 

php 中     include(DEDETEMPLATE."/$cfg_df_style/aaa.htm");

在 aaa.html 文件中进行

<?php
 pasterTempletDiy("/default/aaa-moban .htm");
 ?>

再在aaa-moban.htm中使用 {dede:global.backStr/}

就可以输出 php中的  $backStr 变量

 

 

2)第2种方法 就是在模板文件中输出全局变量

如 <img src='{dede:php}global $_hmtPixel;echo $_hmtPixel; {/dede:php}' width='0' height='0' />

普通分类: