Author Topic: SMFShop Inventory Post Modification  (Read 96502 times)

Offline inkstains

SMFShop Inventory Post Modification
« on: September 10, 2007, 03:37:10 pm »
THIS HAS ONLY BEEN TESTED ON A CLEAN INSTALL OF SMF 1.1.3 AND SMFShop 3.0

WARNING IF YOU INSTALL THIS MOD AND EVER GO TO REMOVE/UPGRADE YOUR INSTALL OF SMFShop YOU MAY ENCOUNTER ERRORS IF THIS MOD IS NOT UNINSTALLED FIRST. YOU'VE BEEN WARNED


IF YOU ARE USING AN EARLIER VERSION PLEASE UNINSTALL AND INSTALL THIS NEW VERSION

Updated and rolled into one package, from admin you can now select whether to enable/disable the IPM (on disable all original postbit settings will be restored) select where you would like the IPM displayed, Signature or Postbit, as well as selecting how many items you would like displayed.

Because this is a work in progress and as much a learning process for myself as modification project I'm going to just keep updating as it develops. but if you do decide to use this on a forum please be sure to check back for any updates, as i'm sure as time goes on i will realise things could have been done differently and better.

Goals for the next build

Introduce an inventory display sorting system to allow for a wider range of conditions (price, category etc)

Finally add the split and display trade items as well and expand on the current tooltips

Expand the admin section

And possibly something to do with members profile page depends




Special Note: Thank you to feeble for helping with the while loop i feel stupid now haha Daniel for telling me about seperating operations and visual output and Basil Beard for giving me a kick in the right direction when i thought **** this **** **** *** of a mod. cheers fellas. now that emmy esque speech is over with onto the pics


Signature


Postbit


Admin





 >:D
« Last Edit: September 25, 2007, 10:13:09 pm by inkstains »

Offline feeble

Re: SMFShop Inventory Post Modification
« Reply #1 on: September 10, 2007, 07:17:00 pm »
very nice

i like the like design as well

Offline inkstains

Re: SMFShop Inventory Post Modification
« Reply #2 on: September 10, 2007, 07:28:44 pm »
cheers glad ya liking it

Offline feeble

Re: SMFShop Inventory Post Modification
« Reply #3 on: September 10, 2007, 07:34:47 pm »
Just taken a look through your package

I know its early days, so I'll only suggest one thing at the moment
change
Code: [Select]
//BEGIN SMFShop Inventory Signature MOD
echo '<fieldset><legend><a href="', $scripturl, '?action=shop;do=invother2;member=', $message['member']['username'], '">View Inventory</a></legend>';

//get the inventory
$result = db_query("
SELECT it.desc, it.image, inv.id
FROM {$db_prefix}shop_inventory AS inv, {$db_prefix}shop_items AS it
WHERE inv.ownerid = {$message['member']['id']} AND inv.itemid = it.id
LIMIT 10", __FILE__, __LINE__);

//item image and tooltip descriptions
$varia = mysql_fetch_assoc($result);
if ($varia == 0){echo "<img src='{$boardurl}/Sources/shop/item_images/blank.gif'>&nbsp;&nbsp;";}

elseif ($varia > 0){
echo "<img src='{$boardurl}/Sources/shop/item_images/{$varia['image']}'title='{$varia['desc']}'>&nbsp;&nbsp;";
$varia = mysql_fetch_assoc($result);
if ($varia > 0) {
echo "<img src='{$boardurl}/Sources/shop/item_images/{$varia['image']}'title='{$varia['desc']}'>&nbsp;&nbsp;";
}
$varia = mysql_fetch_assoc($result);
if ($varia > 0) {
echo "<img src='{$boardurl}/Sources/shop/item_images/{$varia['image']}'title='{$varia['desc']}'>&nbsp;&nbsp;";
}
$varia = mysql_fetch_assoc($result);
if ($varia > 0) {
echo "<img src='{$boardurl}/Sources/shop/item_images/{$varia['image']}'title='{$varia['desc']}'>&nbsp;&nbsp;";
}
$varia = mysql_fetch_assoc($result);
if ($varia > 0) {
echo "<img src='{$boardurl}/Sources/shop/item_images/{$varia['image']}'title='{$varia['desc']}'>&nbsp;&nbsp;";
}
$varia = mysql_fetch_assoc($result);
if ($varia > 0) {
echo "<img src='{$boardurl}/Sources/shop/item_images/{$varia['image']}'title='{$varia['desc']}'>&nbsp;&nbsp;";
}
$varia = mysql_fetch_assoc($result);
if ($varia > 0) {
echo "<img src='{$boardurl}/Sources/shop/item_images/{$varia['image']}'title='{$varia['desc']}'>&nbsp;&nbsp;";
}
$varia = mysql_fetch_assoc($result);
if ($varia > 0) {
echo "<img src='{$boardurl}/Sources/shop/item_images/{$varia['image']}'title='{$varia['desc']}'>&nbsp;&nbsp;";
}
$varia = mysql_fetch_assoc($result);
if ($varia > 0) {
echo "<img src='{$boardurl}/Sources/shop/item_images/{$varia['image']}'title='{$varia['desc']}'>&nbsp;&nbsp;";
}
$varia = mysql_fetch_assoc($result);
if ($varia > 0) {
echo "<img src='{$boardurl}/Sources/shop/item_images/{$varia['image']}'title='{$varia['desc']}'>&nbsp;&nbsp;";
}
}

echo'</fieldset>';
//END SMFShop Inventory Signature MOD
to
Code: [Select]
//BEGIN SMFShop Inventory Signature MOD
//get the inventory
$result = db_query("
SELECT it.desc, it.image, inv.id
FROM {$db_prefix}shop_inventory AS inv, {$db_prefix}shop_items AS it
WHERE inv.ownerid = {$message['member']['id']} AND inv.itemid = it.id
LIMIT 10", __FILE__, __LINE__);
if(mysql_num_rows($result) > 0){
echo '<fieldset><legend><a href="', $scripturl, '?action=shop;do=invother2;member=', $message['member']['username'], '">View Inventory</a></legend>';
while ($row = mysql_fetch_assoc($result)){
echo "<img src='{$boardurl}/Sources/shop/item_images/{$row['image']}'title='{$row['desc']}'>&nbsp;&nbsp;";
}
echo '</fieldset>';
}
//END SMFShop Inventory Signature MOD
« Last Edit: September 10, 2007, 07:38:27 pm by feeble »

Offline inkstains

Re: SMFShop Inventory Post Modification
« Reply #4 on: September 10, 2007, 07:42:37 pm »
yeh that's what i was thinking that's just a loop isn't it? i just wasn't sure how to do it that looks dope though.

one thing when a user has no items it will show the blank.gif image the only reason i say is if the fieldset doesn't haven't something inside of it it loses the borders and just has the view inventory link which doesn't look very good imo. do you know how i would get it so if the members inventory is 0 it will still display the blank.gif image?

could i do it like this?


Code: [Select]
if(mysql_num_rows($result) == 0){
{echo '<fieldset><legend><a href="', $scripturl, '?action=shop;do=invother2;member=', $message['member']['username'], '">View Inventory</a></legend>';
while ($row = mysql_fetch_assoc($result)){
echo "<img src='{$boardurl}/Sources/shop/item_images/blank.gif'>&nbsp;&nbsp;";
}
echo '</fieldset>';}}
}
elseif(mysql_num_rows($result) > 0){
echo '<fieldset><legend><a href="', $scripturl, '?action=shop;do=invother2;member=', $message['member']['username'], '">View Inventory</a></legend>';
while ($row = mysql_fetch_assoc($result)){
echo "<img src='{$boardurl}/Sources/shop/item_images/{$row['image']}'title='{$row['desc']}'>&nbsp;&nbsp;";
}
echo '</fieldset>';}

i haven't tested that but it looks sorta right, i'm still learning so don't know a heap yet. cheers for the cleaner code though feeble i'll update the packages soon.

EDIT: actually the way you had it makes it not display the section at all which is probably a better way to go hmmm i'm not sure i kinda like it there even if they have no items
« Last Edit: September 10, 2007, 07:49:44 pm by inkstains »

Offline feeble

Re: SMFShop Inventory Post Modification
« Reply #5 on: September 10, 2007, 07:49:28 pm »
yes that would work fine
but just change
Code: [Select]
elseif(mysql_num_rows($result) > 0){to
Code: [Select]
else{as it will always be true

Also a small note,
the changes that I suggested, actually, if inventory is 0, the "View Inventory" field will not be displayed, so either solution should be fine.
basically it depends on how you want it to look.

Offline inkstains

Re: SMFShop Inventory Post Modification
« Reply #6 on: September 10, 2007, 07:50:30 pm »
yeh i just noticed that with the view inventory not being shown. not sure about which way to go. cheers for all the help feeble.

Offline feeble

Re: SMFShop Inventory Post Modification
« Reply #7 on: September 10, 2007, 07:55:28 pm »
no worries
there are a few other things that I would like to suggest, but they can wait for another time

but for the most part, its a very nice add on to SMFShop, so I'm sure it'll get used plenty

Offline inkstains

Re: SMFShop Inventory Post Modification
« Reply #8 on: September 10, 2007, 08:00:58 pm »
yeh cool any time

this is the code i'ma go with i'm gonna keep the blank fieldset just for consistency if anyone wants it the other way they can just make the change themselves  :)

Code: [Select]
//BEGIN SMFShop Inventory Signature MOD
//get the inventory
$result = db_query("
SELECT it.desc, it.image, inv.id
FROM {$db_prefix}shop_inventory AS inv, {$db_prefix}shop_items AS it
WHERE inv.ownerid = {$message['member']['id']} AND inv.itemid = it.id
LIMIT 10", __FILE__, __LINE__);
if(mysql_num_rows($result) == 0){
echo '<fieldset><legend><a href="', $scripturl, '?action=shop;do=invother2;member=', $message['member']['username'], '">View Inventory</a></legend>';
while ($row = mysql_fetch_assoc($result)){
echo "<img src='{$boardurl}/Sources/shop/item_images/blank.gif'>&nbsp;&nbsp;";
}
echo '</fieldset>';
}
else{
echo '<fieldset><legend><a href="', $scripturl, '?action=shop;do=invother2;member=', $message['member']['username'], '">View Inventory</a></legend>';
while ($row = mysql_fetch_assoc($result)){
echo "<img src='{$boardurl}/Sources/shop/item_images/{$row['image']}'title='{$row['desc']}'>&nbsp;&nbsp;";
}
echo '</fieldset>';
}
//END SMFShop Inventory Signature MOD


EDIT: I was thinking about putting all the shop items when it's in the left pane inside the fieldset just to make it all look a bit tidier but i dunno how much daniel would like that so i'll prob leave that for the moment. but i def want to add in some code so it only shows up once per page of a thread for each user but that can wait until i learn a little more php


EDIT: PACKAGES UPDATED IN FIRST POST
« Last Edit: September 10, 2007, 08:22:30 pm by inkstains »

Offline feeble

Re: SMFShop Inventory Post Modification
« Reply #9 on: September 10, 2007, 08:27:58 pm »
Apologies made a small mistake
change
Code: [Select]
if(mysql_num_rows($result) == 0){
echo '<fieldset><legend><a href="', $scripturl, '?action=shop;do=invother2;member=', $message['member']['username'], '">View Inventory</a></legend>';
while ($row = mysql_fetch_assoc($result)){
echo "<img src='{$boardurl}/Sources/shop/item_images/blank.gif'>&nbsp;&nbsp;";
}
echo '</fieldset>';
}
to
Code: [Select]
if(mysql_num_rows($result) == 0){
echo '<fieldset><legend><a href="', $scripturl, '?action=shop;do=invother2;member=', $message['member']['username'], '">View Inventory</a></legend>
<img src="{$boardurl}/Sources/shop/item_images/blank.gif">&nbsp;&nbsp;
</fieldset>';
}
« Last Edit: September 10, 2007, 08:41:52 pm by feeble »

Offline inkstains

Re: SMFShop Inventory Post Modification
« Reply #10 on: September 10, 2007, 08:35:53 pm »
ahh true cheers again feeble O0


Packages updated in first post

Offline J-xToF

Re: SMFShop Inventory Post Modification
« Reply #11 on: September 17, 2007, 12:14:17 pm »
Hmm is the pet supposed to show up?
I only see a link with view pets and have to click on it and it brings me to another page.
Is it possible to make the pet show up?


Quote
4] a further section will be offered for those using the SMF Pets mod by Basil Beard in which a users pets can be displayed as the inventory is now with the mouseover description containing the current pets level health hunger ranking etc

oh, guess its not yet done  =/

Offline inkstains

Re: SMFShop Inventory Post Modification
« Reply #12 on: September 17, 2007, 12:57:38 pm »
yeh not done yet. i'll actually do that as a separate mod after a bit of thinking but prob won't have it up for a little while

Offline J-xToF

Re: SMFShop Inventory Post Modification
« Reply #13 on: September 18, 2007, 12:09:19 am »
 O0 well good luck with the mod.   O0

Hope it will appear soon.  ^^

p.s: Anyone knows what smiley pack is installed here?

Offline inkstains

Re: SMFShop Inventory Post Modification
« Reply #14 on: September 19, 2007, 09:20:40 pm »
packages updated just a small change code change no new functions or anything