View Full Version : How to work out a formula from custom fields and display in postbit
Spank
10-29-2007, 08:49 PM
Hi, I'm wondering if anyone knows how to do a formula from the vales of certain custome profile fields and display it in the post bit.
I know $post[fieldx] will display the vale of the filed in the post bit. What I need to do is field7 (divided by) field6 (muliply by) 100 and display the result in the post bit.
Is this even possible?
Thanks :)
Paul M
10-29-2007, 08:56 PM
You will need to do the calculation in a plugin.
Spank
10-29-2007, 08:58 PM
Any idea how this is done? I'm a n00b at this sort of thing lol
Opserty
10-29-2007, 09:02 PM
You can't do it in a template unless you figure a way to make it work in the if conditional, but its not supposed to be there :p
Best bet would be to make a plugin in one of the postbit hooks, postbit_display_complete? I think or something, can't remember off the top of my head.
EDIT: Whoops forgot to refresh.
You can try maybe:
$percentage = (intval($post['field7']) / intval($post['field6'])) * 100;
Spank
10-30-2007, 08:38 AM
Is anyone able to help with this? :)
Dilmah
10-31-2007, 01:32 PM
They did?
Spank
11-01-2007, 01:28 AM
They did what?
Dilmah
11-01-2007, 03:57 AM
Help. If you are still having problems, you need to post what they are.
We can't help unless we know what problems you are having.
Spank
11-01-2007, 06:56 AM
Well the whole thing, I have no idea how to create a plugin or how the formula should be layed out, and thern getting it to display on the postbit.
Analogpoint
11-01-2007, 07:03 AM
Create a plugin on the postbit_display_start hook and add the code posted by Opserty:
$percentage = (intval($post['field7']) / intval($post['field6'])) * 100;
Then edit your postbit template and insert $percentage where you want it displayed.
Spank
11-01-2007, 07:57 AM
thanks for that but how does one create a plugin?
Edit: Oh I see it, I'll give it a try now.
--------------- Added 1193907957 at 1193907957 ---------------
Oh that works perfectly Analogpoint. Thanks very much for your help!
Edit: Also thanks to Opserty, I didn't see the code you posted.
Analogpoint
11-01-2007, 08:43 AM
You're welcome.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.