Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2004, 04:23 PM
Bill Thebert Bill Thebert is offline
 
Join Date: Mar 2002
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default New Conditional in threadbit

My head is just swimming from looking at all these templates, variable names, etc. I'm in way over my head here.

Nevertheless, here's what I want to do:

In my vBulletin installation, I have a forum (id=31) that is acting as a Classified Ad "category". This category contains (at the moment) four forums (ids = 33, 34, 38 & 39) that contain different types of classified ads.

Replies are not permitted in these forums, so every thread contains only one post -- that of the thread starter. (Occasionally one of the moderators will reply to a classified ad, but it's rare.)

I would like to modify the threadbit template used by forumdisplay.php in any of these classified ad forums -- but leave the rest of the forums alone. No changes there.

The change I wish to make is to add a small column between the "Thread/Thread Starter" column, and the "Last Post" column.

I would like this new column to contain the contents of "field9" from the thread starter's user profile. (This is a custom user profile field containing the two-letter State/Province abbreviation of the user.)

I would like the HEADING on this column to be "State".

Can anyone give me guidance in both formulating and placing the proper conditional & query to make this happen? Talk to me like I'm a two year-old, please, because as I said, I'm in way over my head here.

Thanks,

Bill
Reply With Quote
  #2  
Old 03-14-2004, 06:57 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem with doing that is the information shown on the threadbit area is pulled from the thread table. No user information is pulled except for what is stored in the thread table, custom profile feilds are not included in this.

You are going to have to hack your board to achive the result you are looking for, you should try posting a request at www.vbulletin.org
Reply With Quote
  #3  
Old 03-14-2004, 08:00 PM
Bill Thebert Bill Thebert is offline
 
Join Date: Mar 2002
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brad.loo
The problem with doing that is the information shown on the threadbit area is pulled from the thread table. No user information is pulled except for what is stored in the thread table, custom profile fields are not included in this.

You are going to have to hack your board to achive the result you are looking for, you should try posting a request at www.vbulletin.org
As I understand your response, Brad, there would be two ways of skinning this cat:

1) Hack newthread.php so that it writes "field9" from the user profile to the thread table at the time each new thread is created, or

2) hack forumdisplay.php to do a table JOIN in order to retrieve the desired information when the forum is viewed.

Am I correct in that assessment?

If so, is one way any better than the other? I'm thinking #1 is probably wiser, since the WRITE is happening anyway. (What's one more field?) Besides, each thread is created only once, but viewed many times. Seems like a better investment of server MIPs to write the data to the threads table & be done with it.

Am I on track?

Bill
Reply With Quote
  #4  
Old 03-14-2004, 08:51 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes number 1 would be the better option at least imo, it would not add as much overhead as that JOIN would each page view.
Reply With Quote
  #5  
Old 03-15-2004, 01:49 AM
Bill Thebert Bill Thebert is offline
 
Join Date: Mar 2002
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brad.loo
Yes number 1 would be the better option at least imo, it would not add as much overhead as that JOIN would each page view.
Well, I've managed to accomplish #1 above.

I've created a new column in the 'thread' table. And I've tweaked /includes/functions_newpost.php just a tiny little bit, so that 'field9' from the user profile is written to the 'thread' table every time a new thread is created.

See: https://vborg.vbsupport.ru/showthread.php?t=62507 if you're interested in the particulars.

Which brings me back to my initial question.

I would now like to modify the 'threadbit' template in the following ways:

1) Since ALL threads in these Classified Ad forums have ZERO replies, I think I can do without this column on my forumdisplay.php output.

2) I would like to ADD a small column -- to the right of "Thread/ Thread Starter", and to the left of "Last Post" -- to display the contents of this new 'field9' column in my 'thread' table. (Maybe just MOVE the 'replies' column?)

3) I would like these changes to impact ONLY the specified Classified Ad forums. Ideally, I would like the conditional to check for the "category" or parent forum if possible -- so that any new sub-forums I create would also be affected without re-hacking. But if that's not possible, I can specify the individual forum IDs manually.

If I make the new colum the same width as the old "replies" column that I'm removing, it won't muck up the rest of the design too terribly much.

Any guidance for a first-timer re: adding this sort of conditional to the threadbit template?

Regards,

Bill
Reply With Quote
  #6  
Old 03-15-2004, 04:15 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Add this to the phpinclude_start template on a new line:

PHP Code:
// ## Some custom functions to check what type of forum forumid x is
// ## Code credits go to xenon

// ######################## Returns list of forumid's that are customforums #
function fetch_customforum_list()
{
    
$mod_forums '11, 7, 6'// enter your forumid's here
    
return $mod_forums;
}

// #################### This checks if the current forum is a customforum #
function is_custom_forum($forumid 0)
{
    global 
$foruminfo;

    if (
$forumid == 0)
    {
        
$forumid $foruminfo['forumid'];
    }

    eval(
'$retval = in_array($forumid, array(' fetch_customforum_list() . '));');
    return 
$retval;
}

// ## End custom forum functions 
Note this line:

PHP Code:
$mod_forums '11, 7, 6'// enter your forumid's here 
enter the forumid's of all forums you want to show 'field6' in there.

Then in the template FORUMDISPLAY find:

HTML Code:
	<td class="thead" align="center" nowrap="nowrap"><a href="$sorturl&amp;order=desc&amp;sort=replycount">$vbphrase[replies]</a> $sortarrow[replycount]</td>
Change to:

HTML Code:
<if condition="is_custom_forum($thread[forumid])">
<td class="alt1" align="center">$thread[field6]</td>
<else />
<td class="alt1" align="center"><a href="#" onclick="who($thread[threadid])">$thread[replycount]</a></td>
</if>
Then in the template threadbit find:

HTML Code:
<td class="alt1" align="center"><a href="#" onclick="who($thread[threadid])">$thread[replycount]</a></td>
Change to:

HTML Code:
<if condition="is_custom_forum($thread[forumid])">
<td class="alt1" align="center">$thread[field6]</td>
<else />
<td class="alt1" align="center"><a href="#" onclick="who($thread[threadid])">$thread[replycount]</a></td>
</if>
Reply With Quote
Reply


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 12:34 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.05404 seconds
  • Memory Usage 2,233KB
  • Queries Executed 13 (?)
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
  • (4)bbcode_html
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete