vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Placing SIMILAR THREADS Box under First Post or somewhere else instead of LAST (https://vborg.vbsupport.ru/showthread.php?t=283986)

addamroy 06-05-2012 02:11 PM

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!

addamroy 06-08-2012 01:41 AM

Anyone?

addamroy 06-19-2012 10:16 AM

Can somebody please help me here?? In a step-by-step fashion?

kh99 06-19-2012 12:52 PM

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.

addamroy 06-19-2012 05:59 PM

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

kh99 06-19-2012 06:09 PM

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. :)

addamroy 06-19-2012 07:18 PM

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!

kh99 06-19-2012 07:30 PM

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>


addamroy 06-19-2012 07:33 PM

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

kh99 06-19-2012 08:13 PM

lol...I guess it's designed to make you spread it around. It's OK, glad you got it working.

christon26 06-23-2012 07:49 PM

kh99 thank you so much for the help you give in this thread, after much searching to find what I wanted I used your coding (with changes for vb3 lol) on my board, example here: http://www.digiscrapforum.com/showthread.php?t=2287 I think it looks much nicer than the old display :P

bada_bing 02-18-2013 07:21 PM

Hey everyone, great article and looking to do the exact same think, Is this for vb 3.8 ? I get an error when trying to add the code to my postbit_legacy

Thanks

Amaury 02-19-2013 06:10 AM

Quote:

Originally Posted by bada_bing (Post 2405064)
Hey everyone, great article and looking to do the exact same think, Is this for vb 3.8 ? I get an error when trying to add the code to my postbit_legacy

Thanks

This is for vBulletin 4 if you look at the forum name. However, you should create your own thread for this.

bada_bing 02-19-2013 10:10 AM

Quote:

Originally Posted by Amaury25 (Post 2405151)
This is for vBulletin 4 if you look at the forum name. However, you should create your own thread for this.

Thanks for a worthless response

kh99 02-19-2013 12:59 PM

You could try using this in your postbit or postbit_legacy template:

Code:

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

then it seems like the same plugin code should work.

bada_bing 02-19-2013 01:50 PM

Quote:

Originally Posted by kh99 (Post 2405209)
You could try using this in your postbit or postbit_legacy template:

Code:

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

then it seems like the same plugin code should work.



Cool going to try now.

Thanks Again..

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

Quote:

Originally Posted by kh99 (Post 2405209)
You could try using this in your postbit or postbit_legacy template:

Code:

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

then it seems like the same plugin code should work.


OK if I enable the plugin the similar threads dont show up at all. Can you help me identify what in the plugin isnt working ?

kh99 02-19-2013 05:40 PM

Hmm...seems like it should work. The reason it doesn't show at all is because the plugin unsets the $similarthreads variable so that it won't show in the usual place. So the str_replace isn't working - are you sure you put it in the same template you're using (postbit or postbit_legacy), and in the same style that you're viewing? Try doing something like this:

Code:

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

and see if the x shows up at all.

bada_bing 02-19-2013 07:26 PM

Quote:

Originally Posted by kh99 (Post 2405267)
Hmm...seems like it should work. The reason it doesn't show at all is because the plugin unsets the $similarthreads variable so that it won't show in the usual place. So the str_replace isn't working - are you sure you put it in the same template you're using (postbit or postbit_legacy), and in the same style that you're viewing? Try doing something like this:

Code:

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

and see if the x shows up at all.

Thank you so so much after you mentioned if I was putting the code in postbit or postbit_legacy I noticed I was placing it in postbit legacy rather that postbit. testing and working now..

If I wanted to move this above the first post what do I need to change or is that not recommended from a SEO prospective.

kh99 02-19-2013 07:41 PM

If you wanted it above the first post you could just move the part you inserted to be at the top of the postbot template. Or you could probably just edit the SHOWTHREAD template and move the similarthreads code, then you wouldn't need the plugin. I have no idea about SEO.


All times are GMT. The time now is 04:26 AM.

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.02155 seconds
  • Memory Usage 1,784KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (10)bbcode_code_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (19)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete