Show Winners Full Name

A place to discuss and receive support for the Web Auction application.

Show Winners Full Name

Postby zedimus » Wed Dec 10, 2008 10:26 am

I have been trying to show the winners Full Name in the Reports section and on the product page for the admin, i cant get them to work, I just want one to work.

On the product page i have tryed this
Code: Select all
{if isAdmin()}The high bidder is {$record->val('firstname')}{/if}

that just give me a blank space after The high bidder is

and i have tryed this

Code: Select all
{if isAdmin()}The high bidder is {$users->val('firstname')}{/if}


and that just breaks the site template and gives me a sql error.

Do i have to add something else to another file so it knows to take the first and last name or the full name from the high bidder.?

Thanks
David
zedimus
 
Posts: 29
Joined: Tue Jan 15, 2008 2:37 pm

Postby shannah » Wed Dec 10, 2008 2:49 pm

Hi Zedimus,

Where were you trying to add this code? If it was in the templates/view_product.html template, then you're on the right track. You just need to notice that the product record is stored in a variable called $product in that template and not $record.

Now in order to get the winner's full name you'll also need to add a calculated field in the products delegate class to return the full name. Something like:

Code: Select all
function field__winner_full_name(&$record){
    $winner = df_get_record('users', array('username'=>'='.$record->val('high_bidder')));
    if ( !$winner ) return null;
    return $winner->val('firstname').' '.$winner->val('lastname');
}


(assuming that the firstname and lastname columns exist in the users table).

Then in your template you would be able to use this field:

Code: Select all
{$product->val('winner_full_name')}


-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby zedimus » Thu Dec 11, 2008 9:04 am

Thank you steve That worked perfect.

David
zedimus
 
Posts: 29
Joined: Tue Jan 15, 2008 2:37 pm


Return to Web Auction Discussion

Who is online

Users browsing this forum: No registered users and 18 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved