Log in

View Full Version : Display number of items in a user's inventory


laurenannedaniel
12-20-2017, 11:10 AM
Hi again -

Is there a way to display the number of items in a user's inventory? I would think that it would be displaying $total from class_inventory.php but have not yet found the right syntax for it to work.

On my site I have a top bar with their UN, number of new messages, etc. and I wanted to display it there so I think I need something for class_template.php so that I could just put {$total} in my template where I want to display the number.

Thanks!

Dinocanid
12-20-2017, 02:08 PM
You could put this in class_template.php under "private function assignTemplateVars()":
$itemTotal= $mysidia->db->select("inventory", array("iid"), "owner = '{$mysidia->user->username}'")->rowCount();
$this->assign("itemTotal",$itemTotal);

Now in your template.tpl you can display the user's total amount of items in the inventory with {$itemTotal}

laurenannedaniel
12-20-2017, 04:14 PM
That worked perfectly, thanks so much!