Smarty替换字符串并使用另一个变量而不是它

时间:2015-06-10 12:48:17

标签: smarty

我有一个像这样的聪明的表格

 <div class="psmd_content">
    <div class="psmd_text">
      <form class="psmd-form psmd_">
        <div class="psmd-fields">
          {if {$display_fields} == 1 || {$display_fields} == 2 }
          <input type="text" placeholder="Enter first name" name="psmd_fname" class="psmd_fname">
          {/if}
          {if {$display_fields} == 2}
          <input type="text" placeholder="Enter last name" name="psmd_lname" class="psmd_lname">
          {/if}
          <input type="text" placeholder="Enter your email" name="psmd_email" class="psmd_email">
        </div>
        <div class="psmd-btn-cont">
          <button class="psmd-btn">{$submit_button_text}</button>
        </div>
        <div class="psmd-clear"></div>
        <div class="psmd-validation"></div>
        {$popup_content}
      </form>
      <div class="psmd-clear"></div>
    </div>
  </div>

为了捕获这个,我制作了像

这样的代码
{capture name=PSMD_FORM}
  <div class="psmd_content">
    <div class="psmd_text">
      <form class="psmd-form psmd_">
        <div class="psmd-fields">
          {if {$display_fields} == 1 || {$display_fields} == 2 }
          <input type="text" placeholder="Enter first name" name="psmd_fname" class="psmd_fname">
          {/if}
          {if {$display_fields} == 2}
          <input type="text" placeholder="Enter last name" name="psmd_lname" class="psmd_lname">
          {/if}
          <input type="text" placeholder="Enter your email" name="psmd_email" class="psmd_email">
        </div>
        <div class="psmd-btn-cont">
          <button class="psmd-btn">{$submit_button_text}</button>
        </div>
        <div class="psmd-clear"></div>
        <div class="psmd-validation"></div>
        {$popup_content}
      </form>
      <div class="psmd-clear"></div>
    </div>
  </div>
{/capture}

并像这样使用它

{$smarty.capture.PSMD_FORM}

这很好用

但是我有一个变量{$content}当我只是使用这个变量时它会显示我这样的值

ENTER YOUR EMAIL 
{PSMD_FORM}
know about our exclusive items, New catalogs and special promotions

现在我想用我的表单替换{PSMD_FORM}。所以我确实喜欢这个

str_replace({PSMD_FORM}, {$smarty.capture.PSMD_FORM}, {$content}); 但它不起作用。那么有人能告诉我如何解决这个问题吗?任何帮助和建议都会非常明显。感谢

1 个答案:

答案 0 :(得分:0)

这对我有用

pid_no user      20   0  other_info my_app1  
pid_no user      20   0  other_info my_app2  
pid_no user      20   0  other_info my_app3