Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #31  
Old 06-30-2009, 03:41 AM
mikey12561 mikey12561 is offline
 
Join Date: Jun 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

kk just to let you know I change it with the new code you gave us and I still got the same error.
Reply With Quote
  #32  
Old 06-30-2009, 09:54 AM
Speedy131 Speedy131 is offline
 
Join Date: Aug 2003
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

don't want to hijack this thread or anything, but just wanted to ask if i only want to look for the usergroup(s) the threadstarter belongs to, do I also need to work with all that code?

I want to show an image in the threadbit, next to the username of the threadstarter if the threadstarter belongs to usergroup 22 ... that usergroup is an "additional" usergroup.
Reply With Quote
  #33  
Old 06-30-2009, 02:26 PM
DragonBlade's Avatar
DragonBlade DragonBlade is offline
 
Join Date: May 2006
Posts: 189
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mellymonster View Post
For Marital Status Thread Display this right?
Code:
$thread['postusername'] .= $marital_status_threadids[$thread['threadid']];
For Marital Status Thread Query, this?
Code:
($hook = vBulletinHook::fetch_hook('forumdisplay_query')) ? eval($hook) : false;  

// Query to check if/what threadowner's marital status is
$marital_status_threadids = array();
$marital_status_threads_query = sprintf("SELECT thread.threadid, userfield.field17 AS maritalstatus FROM thread LEFT JOIN userfield ON(thread.postuserid=userfield.userid) WHERE thread.threadid IN (0%s)", $ids);
$marital_status_threads_result = $vbulletin->db->query_read($marital_status_threads_query);
while ($marital_status_threads_row = $vbulletin->db->fetch_array($marital_status_threads_result))
  {$marital_status_threadids[$marital_status_threads_row['threadid']] = $marital_status_threads_row['maritalstatus'];}
I'm still getting the big error.
Quote:
Originally Posted by mikey12561 View Post
kk just to let you know I change it with the new code you gave us and I still got the same error.




Hmmm... There is no doubt that it is my code that is causing your error. Line 866 in forumdisplay is where the forumdisplay_query hook is located, and that's where I told you to make that first plugin. I just can't seem to figure out WHY.

This field17 of yours, it's just a string, correct? Like a link to an image or something, not the actual image data, right? I'm not understanding why it's trying to allocate such a huge chunk of memory. I mean, if it was actual binary data (like if you stored the image itself on the database) I guess I could understand...

Could you do me a favour and select five or ten random users, get their userid, run this query (phpMyAdmin, the vBulletin run query bit, or even by the command line, it matters not where), and paste the output for me?

Code:
SELECT field17 AS maritalstatus FROM userfield WHERE userid IN (XXX1,XXX2,XXX3,...,XXXN)
Replace the XXX1,XXX2,XXX3,...,XXXN with the userids. An example could be "IN (34562,43529,11324,74923,2514)".

--------------- Added [DATE]1246376862[/DATE] at [TIME]1246376862[/TIME] ---------------

Quote:
Originally Posted by Speedy131 View Post
don't want to hijack this thread or anything, but just wanted to ask if i only want to look for the usergroup(s) the threadstarter belongs to, do I also need to work with all that code?

I want to show an image in the threadbit, next to the username of the threadstarter if the threadstarter belongs to usergroup 22 ... that usergroup is an "additional" usergroup.
This can actually be done with just a little modification to the $hook_query_fields and $hook_query_joins variables for the call to threads. ]


You will be making a plugin on the hook forumdisplay_query. Title it however you want.

Now, what you want is to join the user table with the thread table, so that you can select values from the user table. The specific field you want is membergroupids. PLEASE NOTE, however, that if for some reason you change around the users' PRIMARY usergroup (something I never do), that this will be an entirely different story! I'm just assuming here that you use secondary usergroups, so let me know if that's not the case!

ALSO NOTE, this first code is assuming that you want to use more than the usergroup '22' at some point in the future. We can uncomplicate things (heh, kind of) if you KNOW that you will only ever want to use usergroup 22, and I'll explain that a bit later.

So, here's the code that needs to go in the plugin, assuming the above:
PHP Code:
$hook_query_fields .= ', user.membergroupids '// This adds the membergroupids field to the data returned
$hook_query_joins .= ' LEFT JOIN user ON(thread.postuserid=user.userid) '// This adds the user table to the query, and searches only the record that matches the postuserid 
Now, this data will be returned in the $thread variable as $thread['membergroupids']. The data itself is a comma-separated list, like "2,5,34,22,78", so in out next plugin, we'll explode that into an array, which will be a bit easier for us to handle with PHP.



Our NEXT plugin goes on the hook, threadbit_display. Title it what you want. :3

The code we'll use will make that list into an array, and will then search the array for the value '22'.
PHP Code:
$thread['membergroupids'] = explode(','$thread['membergroupids']);
$isgroup22 in_array(22$thread['membergroupids']); 
Now, $isgroup22 will be true if the usergroup 22 is included. You can use this variable in an <if condition="$isgroup22">Print this<else />Print That</if> statement in the template, OR (if you have a variable you want to append it to) you can modify it directly in the plugin.

Consider this alternative to the above plugin:
PHP Code:
$thread['membergroupids'] = explode(','$thread['membergroupids']);
if (
in_array(22$thread['membergroupids'])) {$thread['postusername'] .= '<img src="/my/supercool/usergroup/image.png" />';} 
This will just append the image to the username for the thread starter without the need for touching templates. :3






I'll be back in a bit with explanation for if you ONLY ever wanted to use usergroup 22.

--------------- Added [DATE]1246382814[/DATE] at [TIME]1246382814[/TIME] ---------------

Y'know, I really hate this effing "Auto-merged Double-Post" crap. A lot of posts can be read better if their content was seperated better.

[high]* DragonBlade shakes a fist in defiance of the Admins. And is then struck down with the Almighty Ban Hammer. [/high]



ANYWAYS, back to what I was saying. I went over it, and really, the efficiency wouldn't be much better in searching only for usergroup22 in the query, so what I posted is probably best. HOWEVER, there might be a slight bug with the second plugin.

The line,
PHP Code:
$thread['membergroupids'] = explode(','$thread['membergroupids']); 
Assumes that there will be a comma-seperated list, but this is not always the case, so a better way to write it would be:
PHP Code:
$thread['membergroupids'] = ($thread['membergroupids']) ? explode(','$thread['membergroupids']) : array(); 
This makes it so that if there is no value in $thread['membergroupids'], it will return an empty array. It would do the same the other way, but could also throw warnings that would ugly up your page. XP
Reply With Quote
  #34  
Old 06-30-2009, 07:43 PM
Speedy131 Speedy131 is offline
 
Join Date: Aug 2003
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

DragonBlade, you are awesome ! :up::up:

Worked exactly as you described and it's just what I needed, I'm so happy now
Now I also (somewhat) understand that whole hooks thing, that's actually pretty nice.

Once again, thank you very very much
Reply With Quote
  #35  
Old 07-01-2009, 04:49 PM
Mellymonster Mellymonster is offline
 
Join Date: Oct 2008
Posts: 308
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well I used the gender icon in post bit code thing for the marital status...

PHP Code:
<!-- Start Gender On/Off Customization --> 
<if 
condition="$bbuserinfo['field18'] != 'Yes'"
                    <if 
condition="$post[field17]"> <img src="$stylevar[imgdir_misc]/$post[field17].gif" alt="$post[field17]/></if> 
</if> 
<!-- 
End Gender On/Off Customization --> 
It has gender in it cus I didn't know if changing it would hurt anything so I kept it like that.
Reply With Quote
  #36  
Old 07-05-2009, 04:56 AM
Mellymonster Mellymonster is offline
 
Join Date: Oct 2008
Posts: 308
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

DragonBlade, can you help me with this? Please
Reply With Quote
  #37  
Old 11-20-2009, 12:41 PM
deluxmall deluxmall is offline
 
Join Date: Jul 2009
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Speedy131 View Post
don't want to hijack this thread or anything, but just wanted to ask if i only want to look for the usergroup(s) the threadstarter belongs to, do I also need to work with all that code?

I want to show an image in the threadbit, next to the username of the threadstarter if the threadstarter belongs to usergroup 22 ... that usergroup is an "additional" usergroup.
that is what I want to do, any solution??
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:06 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04399 seconds
  • Memory Usage 2,266KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (6)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete