vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Insert a faux post between the first and second posts (https://vborg.vbsupport.ru/showthread.php?t=297671)

markp_2000 04-28-2013 07:11 PM

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?

Lynne 04-28-2013 08:34 PM

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}

markp_2000 04-28-2013 09:02 PM

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
    }


Lynne 04-28-2013 09:34 PM

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?

final kaoss 04-28-2013 10:38 PM

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.

markp_2000 04-28-2013 10:47 PM

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 (Post 2419007)
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

final kaoss 04-28-2013 11:10 PM

It has the ability to exclude usergroups and forums built in :P

markp_2000 04-28-2013 11:12 PM

Quote:

Originally Posted by final kaoss (Post 2419007)
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 (Post 2419017)
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.


All times are GMT. The time now is 02:03 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.01156 seconds
  • Memory Usage 1,742KB
  • 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
  • (6)bbcode_code_printable
  • (1)bbcode_html_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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