Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use a variable in smarty template in following scenario?
    text
    copied!<p>My code is as follows:</p> <pre><code>{if $question_detail.question_has_sub_ques=='yes' &amp;&amp; $question_detail.sub_question} {foreach from=$question_detail.sub_question item=sub_ques_ans key=sub_ques_no} &lt;tr class="oddRow"&gt; &lt;td class="question"&gt; &lt;h4&gt;&lt;strong&gt;Sub-question {$page_question_no+1}.{$sub_ques_no+1}&lt;/strong&gt;&lt;/h4&gt; &lt;ul class="options"&gt; &lt;li&gt;&lt;span&gt;{$sub_ques_ans.question_text}&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/td&gt; &lt;td class="question-id"&gt;QUE{$sub_ques_ans.question_id}&lt;/td&gt; &lt;/tr&gt; {if $sub_ques_ans.question_file!=''} &lt;tr&gt; &lt;td valign="top" colspan="2"&gt; &lt;img src="{$ques_thum_image_path}{$sub_ques_ans.question_id}_{$sub_ques_ans.question_file}"&gt; &lt;/td&gt; &lt;/tr&gt; {/if} {if $question_detail.sub_question_answer_1} &lt;tr class="question_answer evenRow"&gt; &lt;td class="question"&gt; &lt;p class="answers"&gt;&lt;strong&gt;Answers&lt;/strong&gt;&lt;/p&gt; &lt;ol class="options"&gt; {foreach from=$question_detail.sub_question_answer_1 item=sub_ans key=sub_ans_no} &lt;li&gt; {if $sub_ans.answer_is_right==1} {assign var='correct_sub_ans' value=$sub_ans_no+1} {/if} {if $sub_ans.answer_text!=''}{$sub_ans.answer_text}{/if}&lt;br /&gt; {if $sub_ans.answer_file!=''}&lt;img src="{$ans_thumb_img_path}{$sub_ans.answer_id}_{$sub_ans.answer_file}" &gt;{/if} &lt;/li&gt; {/foreach} &lt;/ol&gt; &lt;p class="correct-answer"&gt;&lt;strong&gt;Correct Answer Option : &lt;/strong&gt;{$correct_sub_ans}&lt;/p&gt; &lt;/td&gt; &lt;td class="question-id"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; {/if} {/foreach} {/if} </code></pre> <p>Here you can see a variable <code>{$page_question_no+1}</code>. Now I want to use this variable in following statement as </p> <pre><code>{if $question_detail.sub_question_answer_{$page_question_no+1}} </code></pre> <p>but it's giving error, may I know the correct way of using it properly? Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload