PDA

View Full Version : Setting Variables in Widget


daddel80
03-20-2012, 12:45 PM
Hi,

i'm still in the basics of vb programming and fighting with variable settings. Maybe somebody can give me the solution.

I want to adapt the poll Widget. I want to set a new variable as a counter and fighting with the right syntax. Can somebody tell me how to set the variables if i want to use it in the loop below?

Thanks for your input!


// Here i want to set the initial value} {vb:raw i = 2}
<vb:each from="poll_data" key="threadid" value="poll">
<div class="cms_widget_post_bit widget_post_bit">
<h4 class="cms_widget_post_header widget_post_header"><a href="{vb:link thread, {vb:raw poll}}">{vb:raw poll.question} ({vb:raw poll.totalvotes} {vb:rawphrase votes})</a></h4>
// How to set this if i want count ? i++;
<ol>{vb:raw poll.resultdetail}</ol>
</div>
</vb:each>

-----

<vb:each from="resultdetail" key="seq" value="detail">
<li>
<p class="polloption">{vb:raw detail.option} ({vb:raw detail.votes} {vb:rawphrase votes})</p>

//How to use the variable after the string pollbar?
<div class="pollbar{vb:raw i}" style="width:{vb:raw detail.percentraw}%;"></div>
</li>
</vb:each>

kh99
03-20-2012, 02:39 PM
You can't really put php in a template, so if you need to calculate a value you'd have to modify the php code to calculate it, then register a variable with the value.