Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-05-2012, 03:11 PM
addamroy addamroy is offline
 
Join Date: Sep 2010
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Placing SIMILAR THREADS Box under First Post or somewhere else instead of LAST

Hello, I've been trying like crazy to get this similar threads box under the first post instead of the last post.

Well in fact, I'd like to be able to put the similar threads box wherever I want it I just can't figure out how to use the {vb:raw similarthreads} tag....

This tag only seems to work in the SHOWTHREAD template.

I tried removing it and placing it at the end of the postbit_legacy template but this didn't do anything, nothing showed up.

I removed the {vb:raw similarthreads} tag from the showthread template and it no longer shows on the at the bottom, which tells me at the very least this is the tag that displays the similar threads box, but why is it that I can't place this tag anywhere else in other templates and have it show up?

The end goal, is to have a simple <vb:if is_first_shown>{vb:raw similarthreads}</vbif> (excuse the lack of proper code, just throwing examples out there) type entry in the postbit_legacy template at the bottom... but either way no matter where I put the {vb:raw similarthreads} tag it doesn't work, unless it's in the showthread template.

Ideas? Reason?

Thanks!
Reply With Quote
  #2  
Old 06-08-2012, 02:41 AM
addamroy addamroy is offline
 
Join Date: Sep 2010
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone?
Reply With Quote
  #3  
Old 06-19-2012, 11:16 AM
addamroy addamroy is offline
 
Join Date: Sep 2010
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can somebody please help me here?? In a step-by-step fashion?
Reply With Quote
  #4  
Old 06-19-2012, 01:52 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The reason you can't put {vb:raw similarthreads} in the postbit_legacy template is because a variable has to be registered to a template before you can use it in a vb:raw tag. In addition, the similarthreads section hasn't even been created yet when the posts are being rendered, so there's no way to simply register similarthreads to the postbit_legacy template.

The only (relatively easy) thing I can think of would be to create a plugin using hook showthread_complete. At that point the similar threads section has been created and is in $similarthreads, and the posts section has been created as $postbits. So what you might be able to do is do a str_replace() on $postbits to insert the similar threads, then unset $similarthreads, like:

Code:
if (isset($similarthreads))
{
    $find = "something";
    $postbits = str_replace($find, $similarthreads, $postbits);
    unset($similarthreads);
}

That leaves the question of what to use as "something" and how to get it into postbit_legacy. I was thinking something like an html comment (so if the plugin is disabled it won't be displayed), so maybe "<!-- similar threads -->". Then you'd use something similar to what you posted above, maybe

Code:
<vb:if condition="$post['isfirstshown']"><!-- similar threads --></vb:if>

Anyway, I haven't actually tested this so you might run in to some issues.
Reply With Quote
  #5  
Old 06-19-2012, 06:59 PM
addamroy addamroy is offline
 
Join Date: Sep 2010
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well although that makes perfect sense, (it really does) I haven't got a clue how to use 'hooks' or how to create 'plugins' lol
Reply With Quote
  #6  
Old 06-19-2012, 07:09 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, you did say you wanted step by step. Thing is I haven't tried it so I could step by step you into something that doesn't actually work. But here goes:

1) Edit postbit_legacy, and where you want the similar threads to appear (at the end I suppose), insert this:

Code:
<vb:if condition="$post['isfirstshown']"><!-- similar threads --></vb:if>

2) In the adminCP go to Products & Plugins > Add New Plugin, and find "showthread_complete" in the Hook Location dropdown.

3) Enter a title, something so that later you'll remember what this plugin is for.

4) In the large "Plugin PHP Code" box, enter this:
Code:
if (isset($similarthreads))
{
    $postbits = str_replace('<!-- similar threads -->', $similarthreads, $postbits);
    unset($similarthreads);
}

5) Select the Yes radio button next to Plugin is Active at the bottom, and click Save.


There's a chance it won't work. If it doesn't, post here and maybe I'll have to actually try it.
Reply With Quote
2 благодарности(ей) от:
addamroy, christon26
  #7  
Old 06-19-2012, 08:18 PM
addamroy addamroy is offline
 
Join Date: Sep 2010
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks man you are truly awesome, we're getting somewhere.

What you said works, HOWEVER, just a little bit of formatting issues it seems.

If you recreate what you said (shouldnt cause any issues), it doesn't look the same as it does under the posts like where it shows by default. If we can fix that we're golden!
Reply With Quote
  #8  
Old 06-19-2012, 08:30 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem I have (and the reason that I didn't test this before posting) is that I've never been able to get similar threads to work on a test forum. I really don't understand how they work - I used exactly the same word in the title and body of several threads but they still didn't score high enough to be considered "similar".

Anyway, I was afraid that the formatting might not be right, and I'm not big on the formatting stuff. You probably need to copy more of the surrounding formatting from the SHOWTHREAD template. Try this (where you modified the postbit_legacy template):

Code:
<vb:if condition="$post['isfirstshown']">
<div id="thread_info" class="thread_info block">
<!-- similar threads -->
</div>
</vb:if>
Reply With Quote
  #9  
Old 06-19-2012, 08:33 PM
addamroy addamroy is offline
 
Join Date: Sep 2010
Posts: 352
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's basically removing the extra 'spacing' between posts for some reason. It is there though!

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

Perfect!

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

kinda bummed out it wont let me thank you again until i thank someone else...... sup with that
Reply With Quote
  #10  
Old 06-19-2012, 09:13 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

lol...I guess it's designed to make you spread it around. It's OK, glad you got it working.
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 04:02 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05443 seconds
  • Memory Usage 2,254KB
  • 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
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (2)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete