PDA

View Full Version : Trophy shown by name



Sjf0464
12-08-2017, 09:09 PM
Hi,

Looking at the site http://leagues.gr/football-game?view=standings&season=26&league=18 it shows trophies next to user names in tables, how do I get this to show the same on my site ? I have 2 users who have won trophies but only shows when you go into their stats.
Might be missing an option somewhere.

Regards

kostas
18-08-2017, 01:55 PM
Hello,

this change will require changes to an encoded file, i will attach this file without encoding and you will have to place it in the directory <joomla installation>/components/com_masterleaguepro/views/standings/
Unzip the file first
16

then you will have to change the file <joomla installation>/components/com_masterleaguepro/views/standings/tmpl/default.php

~ Line 122


<td><a href='<?php echo jRoute::_("index.php?option=com_masterleaguepro&view=playerprediction&user=".$item->id); ?>'><?php echo $item->username;?></a></td>


to


<td class='mlp-left'>
<a href='<?php echo jRoute::_("index.php?option=com_masterleaguepro&view=playerprediction&user=".$item->id); ?>'>
<?php echo $item->username;?>
</a>
<?php
if(isset($this->trophies[$item->id])){


//user got trophy (we got 3 type of trophies with id 1,2 and 3)
if(isset($this->trophies[$item->id][1])){
for($j=0;$j<$this->trophies[$item->id][1]["trophy_count"];$j++){
echo "<img alt='".$this->trophies[$item->id][1]["trophy_desc"]."' title='".$this->trophies[$item->id][1]["trophy_desc"]."' src='".$this->trophies[$item->id][1]["trophy_icon"]."'/>";
}
}
if(isset($this->trophies[$item->id][2])){
for($j=0;$j<$this->trophies[$item->id][2]["trophy_count"];$j++){
echo "<img alt='".$this->trophies[$item->id][2]["trophy_desc"]."' title='".$this->trophies[$item->id][2]["trophy_desc"]."' src='".$this->trophies[$item->id][2]["trophy_icon"]."'/>";
}
}
if(isset($this->trophies[$item->id][3])){
for($j=0;$j<$this->trophies[$item->id][3]["trophy_count"];$j++){
echo "<img alt='".$this->trophies[$item->id][3]["trophy_desc"]."' title='".$this->trophies[$item->id][3]["trophy_desc"]."' src='".$this->trophies[$item->id][3]["trophy_icon"]."'/>";
}
}
}
if(isset($this->trophies[$item->id][4])){
for($j=0;$j<$this->trophies[$item->id][4]["trophy_count"];$j++){
echo "<img alt='".$this->trophies[$item->id][4]["trophy_desc"]."' title='".$this->trophies[$item->id][4]["trophy_desc"]."' src='".$this->trophies[$item->id][4]["trophy_icon"]."'/>";
}
}
?>


and last you will have to add code to the file <joomla installation>/components/com_masterleaguepro/models/standings.php
you can place the following code before the closing bracket "}" (last line)



public function getTrophies(){
$query="SELECT ut.user_id,t.id,t.icon,t.description,COUNT(*) as times ".
" FROM `#__masterleaguepro_user_trophy` ut ".
" INNER JOIN `#__masterleaguepro_trophies` t ON t.id=ut.trophy_id ".
" GROUP BY user_id,trophy_id ";


$this->db->setQuery($query);
$trophyList=$this->db->loadObjectList();


$returnArr=array();


foreach ($trophyList as $i => $item) {
$returnArr[$item->user_id][$item->id]=array("trophy_icon"=>$item->icon,"trophy_desc"=>$item->description,"trophy_count"=>$item->times);
}


return $returnArr;
}