PDA

View Full Version : Adding trophies to user profile


Ittermat
12-14-2016, 04:48 PM
I want to add trophies to a users profile- (by making a new tab and whatnot-)

our items are sorted by category, so if I could just put the items in the "trophy" category in their inventory in the tab that'd be awesome (that way when a user gets another one it automatically adds it.)... I just dunno how to do that...

I want the tab after "pets" (http://atrocity.mysidiahost.com/profile/view/Ittermat)
And Id like it to show the tooltip description on hover as well please

This is my profileview.php.

<?php

use Resource\Native\String;
use Resource\Collection\LinkedHashMap;

class ProfileView extends View{

public function index(){
$pagination = $this->getField("pagination");
$users = $this->getField("users");
$document = $this->document;
$document->setTitle($this->lang->title);
$document->addLangvar($this->lang->memberlist);

$iterator = $users->iterator();
while($iterator->hasNext()){
$entry = $iterator->next();
$username = (string)$entry->getKey();
$usergroup = (string)$entry->getValue();
if(cancp($usergroup) == "yes") $document->add(new Image("templates/icons/star.gif"));
$document->add(new Link("profile/view/{$username}", $username, TRUE));
}
$document->addLangvar($pagination->showPage());
}

public function view(){
$mysidia = Registry::get("mysidia");
$user = $this->getField("user");
$profile = $this->getField("profile");
$document = $this->document;
$document->setTitle($this->lang->profile);

$profile->display("aboutme");

$document->add(new Comment('<div id="tabs" class="c-tabs no-js"><div class="c-tabs-nav">',false));
$document->add(new Comment('<a href="#" class="c-tabs-nav__link outer-nav__link is-active">Pets</a>
<a href="#" class="c-tabs-nav__link outer-nav__link">Visitor Message</a>
<a href="#" class="c-tabs-nav__link outer-nav__link">Friends</a>
<a href="#" class="c-tabs-nav__link outer-nav__link">Contact Info</a>
<a href="#" class="c-tabs-nav__link outer-nav__link">Trophies</a>
</div>',false));

// Adopts Tab
$document->add(new Comment('<div class="c-tab outer-tab is-active">
<div class="c-tab__content">',false));
if($user->getadopts()) $document->addLangvar($this->lang->noadopts);
else $profile->display("adopts");

// Visitor Message
$document->add(new Comment('</div></div><div class="c-tab outer-tab">
<div class="c-tab__content">',false));
$vmTitle = new Comment($mysidia->input->get("user").$this->lang->VM_member);
$vmTitle->setBold();
$vmTitle->setUnderlined();
$document->add($vmTitle);
$profile->display("vmessages");

if(!$mysidia->user->isloggedin) $document->addLangvar($this->lang->VM_guest);
elseif(!$mysidia->user->status->canvm) $document->addLangvar($this->lang->VM_banned);
else{
$document->addLangvar($this->lang->VM_post);
$vmForm = new Form("vmform", "{$mysidia->input->get("user")}", "post");
$vmForm->add(new PasswordField("hidden", "user", $user->username));
$vmForm->add(new TextArea("vmtext", "", 4, 50));
$vmForm->add(new Button("Post Comment", "submit", "submit"));
if($mysidia->input->post("vmtext")){
$reminder = new Paragraph;
$reminder->add(new Comment("You may now view your conversation with {$user->username} from ", FALSE));
$reminder->add(new Link("vmessage/view/{$mysidia->input->post("touser")}/{$mysidia->input->post("fromuser")}", "Here"));
$document->addLangvar($this->lang->VM_complete);
$document->add($reminder);
}
else $document->add($vmForm);
}


// Friends.
$document->add(new Comment('</div></div><div class="c-tab outer-tab">
<div class="c-tab__content">',false));
$profile->display("friends", $user);

// The last tab: Contact Info!
$document->add(new Comment('</div></div><div class="c-tab outer-tab">
<div class="c-tab__content">',false));
$user->getcontacts();
$user->formatcontacts();
$profile->display("contactinfo", $user->contacts);

$document->add(new Comment('</div></div>
</div>
<script src="/js/otherTabs.js"></script>
<script>
var myTabs = tabs({
el: "#tabs",
tabNavigationLinks: ".outer-nav__link",
tabContentContainers: ".outer-tab"
});
myTabs.init();

var petTabs = tabs({
el: "#pettabs",
tabNavigationLinks: ".pet-nav",
tabContentContainers: ".pet-tab"
});

petTabs.init();
</script>',false));
}
}
?>

I finally have time to work on my site... sorry for all the questions~!

Dinocanid
12-14-2016, 06:49 PM
I'm afraid I don't exactly know how to work with the setup you have for the profile page since it seems to have a different way of showing the tabs. I can, however, say that this is how I add a new tab with the default code. Maybe it will point you in the right direction?

<?php

use Resource\Native\String;
use Resource\Collection\LinkedHashMap;

class ProfileView extends View{

public function index(){
$pagination = $this->getField("pagination");
$users = $this->getField("users");
$document = $this->document;
$document->setTitle($this->lang->title);
$document->addLangvar($this->lang->memberlist);

$iterator = $users->iterator();
while($iterator->hasNext()){
$entry = $iterator->next();
$username = (string)$entry->getKey();
$usergroup = (string)$entry->getValue();
if(cancp($usergroup) == "yes") $document->add(new Image("templates/icons/star.gif"));
$document->add(new Link("profile/view/{$username}", $username, TRUE));
}
$document->addLangvar($pagination->showPage());
}

public function view(){
$mysidia = Registry::get("mysidia");
$user = $this->getField("user");
$profile = $this->getField("profile");
$document = $this->document;
$document->setTitle($this->lang->profile);
$profile->display("aboutme");
$tabsList = new LinkedHashMap;
$tabsList->put(new String("Visitor Message"), new String("visitormessage"));
$tabsList->put(new String("Adoptables"), new String("adopts"));
$tabsList->put(new String("Friends"), new String("friends"));
$tabsList->put(new String("Contact Info"), new String("contactinfo"));
$tabsList->put(new String("New tab"), new String("newinfo")); //This was added!
$tabs = new Tab(5, $tabsList, 1); //And this!
$document->add(new Comment("<center>"));
$tabs->createtab();

// Here we go with the first tab content: Visitor Message
$tabs->starttab(0);
$vmTitle = new Comment($mysidia->input->get("user").$this->lang->VM_member);
$vmTitle->setBold();
$vmTitle->setUnderlined();
$document->add($vmTitle);
$profile->display("vmessages");

if(!$mysidia->user->isloggedin) $document->addLangvar($this->lang->VM_guest);
elseif(!$mysidia->user->status->canvm) $document->addLangvar($this->lang->VM_banned);
else{
$document->addLangvar($this->lang->VM_post);
$vmForm = new Form("vmform", "{$mysidia->input->get("user")}", "post");
$vmForm->add(new PasswordField("hidden", "user", $user->username));
$vmForm->add(new TextArea("vmtext", "", 4, 50));
$vmForm->add(new Button("Post Comment", "submit", "submit"));
if($mysidia->input->post("vmtext")){
$reminder = new Paragraph;
$reminder->add(new Comment("You may now view your conversation with {$user->username} from ", FALSE));
$reminder->add(new Link("vmessage/view/{$mysidia->input->post("touser")}/{$mysidia->input->post("fromuser")}", "Here"));
$document->addLangvar($this->lang->VM_complete);
$document->add($reminder);
}
else $document->add($vmForm);
}
$tabs->endtab(0);

// The third tab: Adopts...
$tabs->starttab(1);
if($user->getadopts()) $document->addLangvar($this->lang->noadopts);
else $profile->display("adopts");

$tabs->endtab(1);

// The fourth tab: Friends...
$tabs->starttab(2);
$profile->display("friends", $user);
$tabs->endtab(2);

// The last tab: Contact Info!
$tabs->starttab(3);
$user->getcontacts();
$user->formatcontacts();
$profile->display("contactinfo", $user->contacts);
$tabs->endtab(3);


$tabs->starttab(4); //This is the new tab!
$document->add(new Comment("Wow! Things!"));
$tabs->endtab(4);
}
}
?>
To add a tooltip, you can use this code (I'm assuming you use the one from the shop and tooltip mod):
$document->add(new Comment("<img rel='tooltip' title='Description!' src='DIRECT IMAGE LINK'/>"));

Ittermat
12-14-2016, 07:03 PM
Sorry I appreciate the help but it doesnt help me at all XD

draugluin
10-05-2018, 08:53 AM
open classes / class_tab.php

find

public function createtab(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
if($this->num < 2 or $this->num > 5) throw new Exception("The number of tabs must be restricted between 2 to 5!",272);

and change 5 to 6. ( two times ! )


then open css / tabs.css

find

<style type="text/css">


*
body { }
html { overflow-y: scroll; }
a { text-decoration: none; }
a:focus { outline: 0; }
p { margin: 0 0 20px 0; }
#page-wrap { width: 640px; margin: 30px;}

and change the page-wrap width to 740px.


Hope, this helps

Ittermat
11-05-2018, 11:48 AM
I got that part XD but now I have no idea how to make the Trophies actually appear

They're under the category "Trophy" in my items..

I tried this- and that didnt work.. >_<

//trophies
$document->add(new Comment('</div></div><div class="c-tab outer-tab">
<div class="c-tab__content">',false));
$user->getitem();
$profile->display("Trophy", $user);

draugluin
11-06-2018, 01:42 AM
Hmmm.... this works for me. try it...
(profileview.php)

you just have to change the names and the path.

// The new tab
$tabs->starttab(5);
$document->add(new Comment("Throphies!<br> "));

$throphy = $mysidia->db->select("inventory", array("itemname"), "category ='throphy' and owner='{$mysidia->user->username}' ");

while($row = $throphy->fetchObject()) {
$itemname = $row->itemname;
$document->add(new Comment("<img src='/pics/{$itemname}.png'>" ));
}

$tabs->endtab(5);

Ittermat
11-06-2018, 08:51 AM
I got it working (dinocanid helped me) but this thread will be supe useful for future tabs I may want to add- Thank you so much!

(Or if someone else needs to know how)

draugluin
11-06-2018, 09:46 AM
:) you're welcome.