Textpattern CMS support forum

You are not logged in. Register | Login | Help

#41 2019-03-02 09:13:53

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 3,291
Website

Re: geo_vote

Ah, so it’s the language setting that is changing that. Try this small addition to the penultimate line:

function geo_vote_show_results($rs, $message){
$total_votes_percent = array_fill(1, 10, 0);		
				if ($total_votes > 0){
					for ($i = 1; $i <= 10; $i++) {
						$total_votes_percent[$i] = round((${'option_'.$i}/$total_votes)*100, 2);
						}
				}
...
for ($i = 1; $i <= 10; $i++){  
				if (${'option_title_'.$i} != '')	{
		 			$out[] =  '<span class="'.$option_title_class.'">'.doSpecial(${"option_title_".$i}).' ('.$total_votes_percent[$i].'%, '.${"option_".$i}.' '.geo_vote_gTxt('votes').')</span><br />';
		 			//hard coded css for alpha release 
		 			$out[] =  '<div style="background:' . $vote_bar_colour . ';width:' . number_format($total_votes_percent[$i], 2, '.', ',') . '%;height:16px;"></div>';
				}

The change is replacing $total_votes_percent[$i] with this number_format($total_votes_percent[$i], 2, '.', ',') which should reformat the number in the required decimal form to 2 decimal place. If that doesn’t produce the desired effect, then you can also replace it with str_replace($total_votes_percent[$i], ',', '.') to simply replace commas with dots.


TXP Builders – finely-crafted code, design and txp

Offline

#42 2019-03-04 15:18:23

lythande
Member
Registered: 2009-09-08
Posts: 197
Website

Re: geo_vote

jakob wrote #316728:

I’m not familiar with the plugin or its code but you want to alter - slightly to be .'-'. between the two variables if you want the classes to be linked via a hyphen:

if (${'option_title_'.$i} != '') {...

The second thing with the title sounds like the title is being escaped twice in the code somewhere. Without finding the code, I can’t say for sure.

Hi Jakob, much thanks! I have tried this ...'-'.$1.' . Unfortunately I getting an error:
Parse error: syntax error, unexpected '1.' (T_DNUMBER), expecting variable (T_VARIABLE) or '{' or '$' in /.../textpattern/lib/txplib_misc.php(1782) : eval()'d code on line 707

Last edited by lythande (2019-03-04 15:24:32)

Offline

#43 2019-03-04 16:53:33

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 3,291
Website

Re: geo_vote

Hi Lythande, may I take a look on your site? I used to have a login for your site but I don’t know if it’s still active. You know my mail address ;-)


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB