Customizing SMF > SMF Coding Discussion
SMF Shop Item in Post problem
(1/1)
The Wizard:
Note to the admins/Mods: I'm going to only post here in this board and in this thread if it has anything to the SMF Shop Item. I would have deleted the other threads, but I can't so do what you wish with them. Hopefully this will make your lives easier.
PROJECT:
I'm trying to create a item for the SMF shop. The idea is that you buy the item and then it shows up in your profile. In this case I trying to put up a image of a cute dog, but it could be anything up to a pet rock.
As suggested by Kays I have added the following code in the Load.php
--- Code: ---'dog' => userOn($profile['id_member']),
--- End code ---
in $memberContext array after gender.
At the bottom of Load.php before
--- Code: ---?>
--- End code ---
I added the following function -
--- Code: ---//BEGIN SMFShop Cute Dog Item Image Version 0.1
function userOn($id) {
global $smcFunc;
$result_dog = $smcFunc['db_query']('', '
SELECT shop_Dog
FROM {db_prefix}members',
array(
'shop_Dog' => $dog,
)
);
// Show a cute image of a dog
$temp = $smcFunc['db_fetch_assoc']($results);
echo $temp["shop_Dog"];
}
//END SMFShop Cute Dog Item Image
--- End code ---
It was suggested by Kays to
--- Quote ---Then in the function use $id in the query for the member id
--- End quote ---
. I have no idea how to do this.
Then it was suggested by Kays to:
--- Quote ---And finally, in Display.template, you should be able to call it as $message['member']['dog'].
--- End quote ---
Below is what I have for that but I know this is wrong too, and am unsure what to add.
--- Code: ---echo '<li class="gender">', 'Dog Test', ': ', $message['member']['dog'], '</li>';
--- End code ---
If anybody can show me where the yellow brick road is please do.
I would also like to thank anybody who has helped me.
Wiz
The Wizard:
Hello:
After trying a bunch of things I went back to basics and am now trying another approach to this problem:
I added the following into my DisplayTemplate.php:
--- Code: ---// Show SMFShop Item Cute Dog Image Version 0.1
onUser();
--- End code ---
This will call the function from the load.php page and so I only will have to worry about the function onUser at the moment.
I reworked my function and this is what I have so far:
--- Code: ---//BEGIN SMFShop Item Cute Dog Image Version 0.1
function onUser () {
global $smcFunc;
$result_dog = $smcFunc['db_query']('', '
SELECT id_member, member_name, shop_Dog
FROM {db_prefix}members
WHERE id_member = {id_member}',
array(
'id_member' => $message['member']['id'],
'member_name' => $name,
'shop_Dog' => $dog,
)
);
$row_dog = $smcFunc['db_fetch_row']($result_dog);
if($row_dog['shop_Dlag'] !== "") {
echo "Cute Dog: <img src='{$boardurl}/Sources/shop/dog_images/{$row_dog['shop_Dog']}.png'><br>";
}
//END SMFShop Item Cute Dog Image Version 0.1
--- End code ---
I believe the database info is correct now. Right now I'm getting this error message -
--- Quote ---Parse error: syntax error, unexpected $end in /Sources/Load.php on line 2824
--- End quote ---
I'm thinking the error has something to do with the db_fetch_row. If you know the answer or have a idea please help.
Thanks
Wiz
Navigation
[0] Message Index
Go to full version