SimplePortal
Customization => Custom Coding => Topic started by: KahneFan on February 05, 2009, 11:49:07 PM
-
Would it be possible to add to the User Info block...
Posts: ###
Next Level: ###
Total Messages: ##
New Messages: ##
with the "Next Level" acting as a countdown until the next user level? This might inspire users to posts more just to hit that next level.
-
SPortal2.php
Find:
//If you install the Membercolor Link the colors will be autmaticly set.
Replace:
global $smcFunc;
$request = $smcFunc['db_query']('', '
SELECT min_posts
FROM {db_prefix}membergroups
WHERE min_posts > {int:current}
ORDER BY min_posts
LIMIT 1',
array(
'current' => $memberContext[$member_id]['posts'],
)
);
list ($next_post) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
$next_post_left = $next_post - $memberContext[$member_id]['posts'];
//If you install the Membercolor Link the colors will be autmaticly set.
Then you can use $next_post_left where you want it to appear.
-
I apologize, I'm still learning the ins/outs of SP. In order to insert it into the User Info box as above, which file(s) would I add $next_post_left to?
-
No problems. You should use that in the same function. Like this:
SPortal2.php
Find:
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['posts'], ': ',$memberContext[$member_id]['posts'],'<br />';
Replace:
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['posts'], ': ',$memberContext[$member_id]['posts'],'<br />';
echo '
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> Next Post Level: ', $next_post_left, '<br />';
-
Outstanding, thanks! ;D
-
Mr. Blue is slick with the coding :mouse:
lol nice and thanks.. might get around to trying it out :nervous-happy:
-
Wow, this works perfectly :D
Why not just add this as an option for that block in the next update?
-
I had to remove the WHERE part to stop it giving me a db error.
Thing is that for members that aren't part of a post based group it shows the db default which is '-1'
Then again I've not tried it on the portal itself I'm trying the code for within posts in display.php but still same code applies pretty much.
Could you show me how I could do an if/else statement so if $post_next_level = -1 then it should use the members secondary group which by default should be post based group.
Thank you.
-
SiNaN, should this work with 2.2?
-
Try it ?
Should do no ?
The code worked on my display.template for smf2
Except it should be based on your id_post_group and not on your primary id_group which far as I can tell you need to tell the query that your id_group = id_post_group which is found in 'members' and not membergroups.
I think.
I'm not very clued up on mysql.
Giving me an headache. :P
-
For 2.2 (SMF 2.0 RC1):
SPortal2.php
Find:
$member_info['karma']['total'] = $member_info['karma']['good'] - $member_info['karma']['bad'];
Replace:
$member_info['karma']['total'] = $member_info['karma']['good'] - $member_info['karma']['bad'];
global $smcFunc;
$request = $smcFunc['db_query']('', '
SELECT min_posts
FROM {db_prefix}membergroups
WHERE min_posts > {int:current}
ORDER BY min_posts
LIMIT 1',
array(
'current' => $member_info['posts'],
)
);
list ($next_post) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
$next_post_left = $next_post - $member_info['posts'];
Find:
<li>', sp_embed_image('dot'), ' <strong>', $txt['posts'], ':</strong> ', $member_info['posts'], '</li>';
Replace:
<li>', sp_embed_image('dot'), ' <strong>', $txt['posts'], ':</strong> ', $member_info['posts'], '</li>
<li>', sp_embed_image('dot'), ' <strong>Next Post Left:</strong> ', $next_post_left, '</li>';
Moving this to the Custom Coding (http://simpleportal.net/index.php?board=39.0) board as this will not be a default feature.
-
That gave me a 500 error?
-
Take the change back. That error is quite normal when you have a database error in built-in block codes. Are you using SMF 2.0 RC1?
-
I undid the change, yes I have RC1
-
Now I have SimplePortal 2.2 installed on a SMF 2.0 RC1 forum and the edit I gave above works perfectly. Would you attach your SPortal2.php file here so that I can check it?
-
Here ya go...thanks for the help
-
Here you are. Tested on my forum too.
As a note, either your editor or your FTP Client replace the line brakes in your files for some reason. I see them double in my editor.
-
Perfect! Thank you very much!
LOL Only thing is that is says..." Next Post Left: -1152" cuz I already reached the max posts. Easy enough though, just increase the next post level :D
Thanks again
-
Lol. Use this then. :D
-
There we go! Thanks a lot!
-
You're welcome!
-
Ok I lied, it's almost perfect how about saying what the next post level is? :D
I know you're busy supporting the new release but when you get a moments that would be cool.
-
Okay, I'm in a good mood today. :P
-
You are da Bomb! Thanks again!
-
can you tell me how I could get the info based from the users post group rather than their primary group as none post based groups are by default set at "-1".
id_post_group is found in "members" and not "membergroups"
Thank you.
-
Sorry but I couldn't get the relation between primary group, -1 and this. Could you elaborate your question?
-
Hmmm Ok.
In my mySQL database all members that are assigned to none post based groups like admin, global moderators, vip members and producers have "-1" as default in in membergroups min_posts but in the db in members each member also has id_post_group which is the users true post group rather then being based on membergroups id_group which is based on users primary group which in my case most members are in a none post based group called producers.
I was wondering how to make it so that it works from members id_post_group rather than their primary group id.
Thank you & sorry for the epic reply I'm not very good at explaining things.
-
So you don't want the Next Level to be calculated/displayed when user has a primary group set?
-
There's nothing to calculate.
I'd like it to get the users id_group based on member id_post_group
Then even if user has a none post based primary group it will still display the levels until next post based count.
I think. :P
I'm not very good with this mysql query stuff.
Taaa :thumbsup:
-
Codes I gave gives you the count of posts needed for next level of post count based group regardless of the users' primary group status. Even if user has a non-post count based primary group, it will give the correct next level post count value.
-
Oh right, sorry mate.
I guess it must be my end as I was trying to apply it to display.template within threads so I guess it must be applying the same thing to each person.
-
What codes are you using there? The same won't work.
-
I noticed.
The other coder on my site said he would look into it tomorrow.
I was trying to make %bars using bar.gif and sums depending on what users post group is.
It works fine with the first if statement but for all the rest of the users with more than the first if statement it just displays bar at 100% and isn't going to the next elseif.
Like I said I'm not very efficient with mySQL, sorry to bother you.
-
I got your code to work on display.template.php
for user info on threads. :D
Now to get the graph code working.
I think I should be able to get that working now taaa.
// setup next level
global $smcFunc, $memberContext;
$request = $smcFunc['db_query']('', '
SELECT min_posts
FROM {db_prefix}membergroups
WHERE min_posts > "'.$message['member']['posts'].'"
ORDER BY min_posts
LIMIT 1',
array(
)
);
list ($next_post) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
$next_post_left = $next_post - $message['member']['posts'];
// show next level
echo 'Nxt Lvl In: ', $next_post_left, ' Posts<br/>';
-
echo '<img src="', $settings['images_url'], '/bar.gif" width="', (int) (($next_post_left/$next_post) * 100), '" height="15" alt="" />';
-
Perfect, thanks!!
-
Thanks :thumbsup:
I'll try that now.
Not been having much luck at my end :P
Ok that makes go down backwards like how I started off earlier on.
I made a calculation to make it go upwards instead but the problem is that it doesn't take into account that with each level it needs to reset to 100% full or 0% depending on whether you are decreasing or increasing the bar.
So I made a few $variables to try and make it remove the previous $next_post from both the $message['member']['post's] & the $next_post total but for some reason it isn't taking them into account.
I'll figure it out though- eventually.
HaHa this php & sql stuff is complicated.