【问题标题】:phptal - using defined variables in php conditionsphptal - 在 php 条件下使用定义的变量
【发布时间】:2012-08-29 10:40:51
【问题描述】:

我想在 php 条件下使用 phptal 定义的变量,如下所示:

...
<tal:block define="className php: (photoIndex < 10) ? 'thumbItem thumbColumn1' : ( (photoIndex == 10) ? 'thumbItem thumbColumn2 thumbReset' : 'thumbItem thumbColumn2' )">
<tal:block define="defaultVal photo/isDefault">
<tal:block define="classNameWithIndex php: defaultVal ? '${className} modalMegaPhotoSelect' : '${className}'">
<li tal:attributes="class classNameWithIndex">
...

这里我的输出是“${className} modalMegaPhotoSelect”,我希望它是“thumbItem thumbColumn1 modalMegaPhotoSelect” - 确切的期望是无关紧要的想法是 className 应该被视为一个变量 -

感谢您的宝贵时间。

【问题讨论】:

    标签: phptal template-tal


    【解决方案1】:

    只需使用className,而不是'${className}'

    使用className . ' modalMegaPhotoSelect' 代替'${className} modalMegaPhotoSelect'. 周围有空格)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-06
      • 2015-08-30
      • 1970-01-01
      相关资源
      最近更新 更多