Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Rounding a template var.
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #18
RE: Rounding a template var.
It all works, thank you very much indeed.

For those who may be interested, this was the final approach:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<setvar rq1>$GLOBALS['threadfields']['pfrating1']</setvar>
<setvar rq2>$GLOBALS['threadfields']['pfrating2']</setvar>
<setvar rq3>$GLOBALS['threadfields']['pfrating8']</setvar>
<setvar rq4>$GLOBALS['threadfields']['pfrating10']</setvar>
<setvar rq5>$GLOBALS['threadfields']['pfrating11']</setvar>
<setvar rq6>$GLOBALS['threadfields']['pfrating12']</setvar>
<setvar rq7>$GLOBALS['threadfields']['pfrating13']</setvar>
<setvar rq8>$GLOBALS['threadfields']['pfrating29']</setvar>
<setvar myratings>array_filter_blank(array($tplvars['rq1'],$tplvars['rq2'],$tplvars['rq3'],$tplvars['rq4'],$tplvars['rq5'],$tplvars['rq6'],$tplvars['rq7'],$tplvars['rq8']))</setvar>
<setvar or>count($tplvars['myratings']) ? array_sum($tplvars['myratings']) / count($tplvars['myratings']) : 0</setvar>

<ul class="pflist">
<li><label>Price: </label>
<ul class="star_rating reviewer" title="<?=round($tplvars['rq1'])?> of 5 stars">
			<li style="width: <?=round($tplvars['rq1']*2)?>0%;" class="current_rating"></li>
		</ul>

</li>
<li><label>Overall Rating: </label>
<ul class="star_rating reviewer" title="<?=round($tplvars['or']*2)/2?> of 5 stars">
			<li style="width: <?=round($tplvars['or']*2)?>0%;" class="current_rating"></li>
		</ul>

</li>
</ul>


I used the tplvars in the array filter because I have a lot of templates and this setup is suitable for using across all templates as a sort of code snippet; I am also using the variables I set for each field in the ratings later in the page.



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 05-14-2013 07:51 PM by leefish.)
05-14-2013 06:48 PM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Rounding a template var. - leefish - 04-21-2013, 04:42 AM
RE: Rounding a template var. - ZiNgA BuRgA - 04-21-2013, 04:58 PM
RE: Rounding a template var. - leefish - 04-21-2013, 06:17 PM
RE: Rounding a template var. - ZiNgA BuRgA - 04-21-2013, 07:30 PM
RE: Rounding a template var. - leefish - 04-21-2013, 08:19 PM
RE: Rounding a template var. - ZiNgA BuRgA - 04-21-2013, 09:39 PM
RE: Rounding a template var. - leefish - 04-21-2013, 09:47 PM
RE: Rounding a template var. - leefish - 05-05-2013, 02:20 AM
RE: Rounding a template var. - ZiNgA BuRgA - 05-05-2013, 10:09 PM
RE: Rounding a template var. - leefish - 05-10-2013, 02:36 AM
RE: Rounding a template var. - ZiNgA BuRgA - 05-10-2013, 09:37 AM
RE: Rounding a template var. - leefish - 05-10-2013, 06:04 PM
RE: Rounding a template var. - ZiNgA BuRgA - 05-12-2013, 11:04 AM
RE: Rounding a template var. - leefish - 05-12-2013, 11:48 PM
RE: Rounding a template var. - ZiNgA BuRgA - 05-13-2013, 02:11 PM
RE: Rounding a template var. - leefish - 05-13-2013, 09:25 PM
RE: Rounding a template var. - ZiNgA BuRgA - 05-14-2013, 09:34 AM
RE: Rounding a template var. - leefish - 05-14-2013 06:48 PM

 Standard Tools
Forum Jump: