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 04-28-2013, 07:11 PM
markp_2000 markp_2000 is offline
 
Join Date: Jul 2006
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Insert a faux post between the first and second posts

I am trying to insert a faux post between the first and second post of a thread.

I can't quite get if figured out.

I have a template modeled after the postbit template called postbit_faux.

Code:
<li class="postbitlegacy postbitim postcontainer" id="post_faux">
	<div class="posthead">
			<span class="faux-header">Community FAQ</span>
	</div>
	<div class="postbody">
		<div class="postrow">
			<div id="post_message_faux">
				{vb:raw fauxmessage}
			</div>
		</div>
	</div>
	<div class="faux-postfoot">
		<a href="faux.php?{vb:raw session.sessionurl}t={vb:raw threadid}"><img src="{vb:stylevar imgdir_button}/edit.gif" alt="{vb:rawphrase edit_delete_lock_faux}" border="0" /></a>
	</div>
	<hr />
</li>
I am using the following hooks

Code:
Hook location: cache_templates

// for a single template
if ($THIS_SCRIPT == 'showthread') {
    $cache[] = 'postbit_faux';
}
Code:
Hook location: showthread_postbit_create

    // posbit 
        $templater = vB_Template::create('postbit_faux'); 
            $templater->register('fauxmessage',$thread['fauxmessage']; 
            $templatevalues['fauxmessage'] = $templater->render(); 
        vB_Template::preRegister('SHOWTHREAD', $templatevalues);
The template does not cache (it shows up in red) and the template is not being displayed.

I have been following this thread (https://vborg.vbsupport.ru/showthrea...ht=preregister) but no love.

I looked at this thread (https://vborg.vbsupport.ru/showthread.php?t=279650) and though the may be the ticket but I did not want to modify the postbit template.

Can I use a hook to accomplish what is in the above thread?
Reply With Quote
  #2  
Old 04-28-2013, 08:34 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The template isn't cached because it isn't $THIS_SCRIPT, it should be simply THIS_SCRIPT.

And what did you add to the SHOWTHREAD template to get this code/template to display? Since all the posts are added by this single line in that template, I really can't see how you think what you are doing is going to add something between the first and second post:

HTML Code:
{vb:raw postbits}
Reply With Quote
  #3  
Old 04-28-2013, 09:02 PM
markp_2000 markp_2000 is offline
 
Join Date: Jul 2006
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I used this if statement to intercept the create of the postbit.

Code:
if ($show['fauxcanview'] === true AND $counter == 1 AND $fetchtype == 'post' AND $post['visible'] == 1) 
    { 
MY CODE HERE
    }
Reply With Quote
  #4  
Old 04-28-2013, 09:34 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't see how that is going to work in the SHOWTHREAD template. $postbits is already defined by the time the template is being rendered, so exactly how are you going to slip a post into that array while in the SHOWTHREAD template?
Reply With Quote
  #5  
Old 04-28-2013, 10:38 PM
final kaoss final kaoss is offline
 
Join Date: Apr 2006
Posts: 1,314
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

We already have a mod for inserting messages/ads where you are asking for them.
https://vborg.vbsupport.ru/showthread.php?t=239981

Simply download that and input whatever you want into it.
Reply With Quote
  #6  
Old 04-28-2013, 10:47 PM
markp_2000 markp_2000 is offline
 
Join Date: Jul 2006
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK - I missed the last part of my if statement.

Code:
    if ($show['fauxcanview'] === true AND $counter == 1 AND $fetchtype == 'post' AND $post['visible'] == 1) 
    { 
        require_once(DIR . '/includes/class_bbcode.php'); 
        $bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list()); 
        $thread['fauxmessage'] = $bbcode_parser->parse($thread['fauxmessage'], $foruminfo['forumid']); 

            $templater = vB_Template::create('postbit_faux'); 
            $templater->register('fauxmessage',$thread['fauxmessage']; 
            $templatevalues['fauxmessage'] = $templater->render(); 
        vB_Template::preRegister('SHOWTHREAD', $templatevalues);

   eval('$template_hook[\'postbit_end\'] .= "' . fetch_template('postbit_faux') . '";'); 
    }
--------------- Added [DATE]1367192936[/DATE] at [TIME]1367192936[/TIME] ---------------

Quote:
Originally Posted by final kaoss View Post
We already have a mod for inserting messages/ads where you are asking for them.
https://vborg.vbsupport.ru/showthread.php?t=239981

Simply download that and input whatever you want into it.
I'll take a look. We don't what every forum to have this. But I can probably modify to suit.

Mark
Reply With Quote
  #7  
Old 04-28-2013, 11:10 PM
final kaoss final kaoss is offline
 
Join Date: Apr 2006
Posts: 1,314
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It has the ability to exclude usergroups and forums built in :P
Reply With Quote
  #8  
Old 04-28-2013, 11:12 PM
markp_2000 markp_2000 is offline
 
Join Date: Jul 2006
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by final kaoss View Post
We already have a mod for inserting messages/ads where you are asking for them.
https://vborg.vbsupport.ru/showthread.php?t=239981

Simply download that and input whatever you want into it.
Thanks!! I think I see my issue. I need to use the $template_hook.

OK - here is my final code.

I used the showthread_post_start hook location instead of the postbit_display_complete. I don't know if it make a difference both are only called once.

Code:
	if ($show['fauxcanview'] === true AND $counter == 1 AND $fetchtype == 'post' AND $post['visible'] == 1)
	{
		$templater = vB_Template::create('postbit_faux');
			$templater->register('fauxmessage', $threadinfo['fauxmessage']);
			$templater->register('threadid', $threadinfo['threadid']);
		$template_hook['postbit_end'] .= $templater->render();  
	}
Mark

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

Quote:
Originally Posted by final kaoss View Post
It has the ability to exclude usergroups and forums built in :P
This is not an ad. It is a user created post that can summarize a thread. Such as if a thread goes on for 50 pages you can continue to pull the best or updated info to the front. A good example is when some one here posts a mod and then "reserves" the first post after the mod post. You don't have to do that since you will always have that for your use.
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:40 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.04120 seconds
  • Memory Usage 2,239KB
  • 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
  • (6)bbcode_code
  • (1)bbcode_html
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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