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

Reply
 
Thread Tools Display Modes
  #1  
Old 12-17-2011, 07:32 PM
Infoman4ever Infoman4ever is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Which hook to use?

Hi,
I added a new column to "thread" table and performed a plugin to fill it with a particular data relative to each thread and everything went well, but what I'm stacking on is Where to show this column on "showthread.php", I used this tag:
HTML Code:
{vb:raw threadinfo.my_new_column}
I copy-pasted it manually on "showthread" template and it worked but not in where I want, I want to show it near to date of publication on the "posthead" above the first post of the thread, what I'm looking for is which hook should I use to display my data on the proper area?

Regards.
Reply With Quote
  #2  
Old 12-18-2011, 03:25 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not sure I understand what you mean. If you pasted it in the SHOWTHREAD template and it works, why not just paste it where you want it? If you mean that you want it to be inserted by your plugin code so that you don't have to edit the template manually, then it can be done but it gets a little tricky. You basically need to do a str_replace() on the cached template before it's used. Also you can't put in template "curly brace" tags that way, you would need to insert a string.
Reply With Quote
  #3  
Old 12-18-2011, 12:23 PM
Infoman4ever Infoman4ever is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
If you pasted it in the SHOWTHREAD template and it works, why not just paste it where you want it?
I tried in couple places but did not get it where I want, I want it to be displayed here (attached), that I should know the hook corresponding to this place, right?

Quote:
Originally Posted by kh99 View Post
If you mean that you want it to be inserted by your plugin code so that you don't have to edit the template manually
Yep, here we are.

Quote:
Originally Posted by kh99 View Post
You basically need to do a str_replace() on the cached template before it's used. Also you can't put in template "curly brace" tags that way, you would need to insert a string.
Well, not really clear, what is "cached template"? the one I create manually or what? please give me -such a beginner - more details.
Thank you kh99, waiting forward...
Attached Images
File Type: png VBAttachement.png (5.9 KB, 0 views)
Reply With Quote
  #4  
Old 12-18-2011, 12:42 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Infoman4ever View Post
Well, not really clear, what is "cached template"? the one I create manually or what? please give me -such a beginner - more details.
Thank you kh99, waiting forward...

Unfortunately it's difficult, I could write pages and still not explain everything (partly because I don't fully understand it myself). But in this case I happen to have a mod that changes the SHOWTHREAD template. It uses the showthread_getinfo hook location and has code like this
Code:
$find = "some string";
$replace = "other string";
$vbulletin->templatecache['SHOWTHREAD'] = str_replace($find, $replace, $vbulletin->templatecache['SHOWTHREAD']);

but, $vbulletin->templatecache contains compiled templates so it doesn't look like what you see in the template editor. That makes it tricky to know what you can search for and match. You could look in the template table in the database, the "template" column shows the compiled template. Or what I usually do is put in temporary code to write the cached template string to a file, like

Code:
$fp = fopen("showthread.txt", "wb");
fwrite($fp, $vbulletin->templatecache['SHOWTHREAD']);

Then I open that file in my editor so I can refer to it.

I hope that makes some sense.
Reply With Quote
  #5  
Old 12-18-2011, 04:34 PM
Infoman4ever Infoman4ever is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, where to put these lines please?
And, why would it be difficult? if I could do it with a hook 'showthread_getinfo', I thought I can do it with another, I just don't know what is it, I saw couple of products with double of what I want, so I still believe it's not that difficult Thanks deeply Mr kh99.
Reply With Quote
  #6  
Old 12-18-2011, 04:47 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Put those lines in a plugin using hook location 'showthread_getinfo'.

Maybe 'difficult' is the wrong word, maybe 'tricky' is better. Because like I said you might look at the template and try to match a certain string, but that string might not exist in the compiled template so you need to look at the compiled string to be sure.
Reply With Quote
  #7  
Old 12-18-2011, 04:58 PM
Infoman4ever Infoman4ever is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

We did a good progress till now, just one thing to know is where are they these compiled strings?
Reply With Quote
  #8  
Old 12-18-2011, 05:13 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The compiled string in the "template" database table, in the "template" column. The fopen and fwrite lines above are meant to be a "one-time" thing to print the compiled string to a file so you could look at it more easily.

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

OK, based on the PM you sent me, I guess I misunderstood and your problem is that you can't find the place in the template to insert your change. So I looked but the problem is that I can't find anything that looks like your picture. What version of vb are you running, and what style are you using?
Reply With Quote
  #9  
Old 12-18-2011, 08:54 PM
Infoman4ever Infoman4ever is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, it's not exactly alike, I just put the image to make you know the place (the date and time above the post like the first post: "Yesterday, 21:32" and above any other post also).
I'm using (vBulletin 4.1.5), and the basic style.
Regards.
Reply With Quote
  #10  
Old 12-18-2011, 09:02 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh..lol, I see now, it's actually *this* site. But if you want to put it there, the reason you can't find it in SHOWTHREAD is because that's part of the postbit template (or maybe postbit_legacy if you're using that). So look at postbit, and if you want it to only be in the fist post you can use a condition like:

Code:
<vb:if condition="$post['isfirstshown']">your html</vb: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 02:37 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.04736 seconds
  • Memory Usage 2,282KB
  • 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
  • (1)bbcode_html
  • (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
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (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
  • 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
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete