The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
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>
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);
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? |
|
#2
|
||||
|
||||
|
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}
|
|
#3
|
|||
|
|||
|
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
}
|
|
#4
|
||||
|
||||
|
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?
|
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
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') . '";');
}
Quote:
Mark |
|
#7
|
|||
|
|||
|
It has the ability to exclude usergroups and forums built in :P
|
|
#8
|
|||
|
|||
|
Quote:
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();
}
--------------- Added [DATE]1367196421[/DATE] at [TIME]1367196421[/TIME] --------------- 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. |
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|