1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. If you want premium products then purchase our VIP or SVIP plans
  3. Dont forget read our rules HERE Also anyone caught Leeching this content or Scamming will be banned on numerous networks.
    Dismiss Notice
  4. Dont forget we do not allow Multiple Accounts, so all of your accounts as well as your IP will be banned.
    Dismiss Notice
  5. Tired of Download Limits ? UPGRADE Today!
    Dismiss Notice

How to bring back showpost in vBulletin 4.x

Discussion in 'Vbulletin' started by HAWK, May 8, 2016.

  1. HAWK

    HAWK Administrator Staff Member ADMIN

    Likes Received:
    1,143
    Trophy Points:
    113
    Gender:
    Male
    For sometime some people have been asking how to bring back the ability to show only a single post in vBulletin 4. In vBulletin 3.x this was done with the "showpost.php" file. While vBulletin 4 maintains this file if you try to use it you find yourself sent back to the more familiar showthread.php file that displays all the posts on a page in a thread.

    Supposedly showpost was removed from VB4 for SEO issues, but regardless the reason most people seem to prefer it as it is.

    However, if you are one of the few with need for showpost this will get you started. It is not complete but it will get you a working showpost page.

    The reason this can not be made into a modification is a legal one- Virtually all the code is original copyrighted vBulletin code so it can not be distributed by anyone else, modification or not.

    Here are more detailed instructions.

    There are two main parts-

    Part 1 is modifying showpost.php and part 2 is creating a new template.

    Part 1.

    Like I said earlier, showpost.php is still a file included in vBulletin 4. Some popular modifications have been designed to use this original showpost.php file so we do not want to edit the original file.

    Instead step 1 is to create a copy of showpost.php and rename the copy to showpostvb4.php.

    In this new showpostvb4.php file make the following edits:

    Find:

    Code:
    // pre-cache templates used by all actions
    $globaltemplates = array(
        'im_aim',
        'im_icq',
        'im_msn',
        'im_yahoo',
        'im_skype',
        'postbit',
        'postbit_wrapper',
        'postbit_attachment',
        'postbit_attachmentimage',
        'postbit_attachmentthumbnail',
        'postbit_attachmentmoderated',
        'postbit_ip',
        'postbit_onlinestatus',
        'bbcode_code',
        'bbcode_html',
        'bbcode_php',
        'bbcode_quote',
        'bbcode_video',
    );
    Add a new line to it:

    Code:
    // pre-cache templates used by all actions
    $globaltemplates = array(
        'im_aim',
        'im_icq',
        'im_msn',
        'im_yahoo',
        'im_skype',
        'postbit',
        'postbit_wrapper',
        'postbit_attachment',
        'postbit_attachmentimage',
        'postbit_attachmentthumbnail',
        'postbit_attachmentmoderated',
        'postbit_ip',
        'postbit_onlinestatus',
        'bbcode_code',
        'bbcode_html',
        'bbcode_php',
        'bbcode_quote',
        'bbcode_video',
        'SHOWTHREAD_SHOWPOSTVB4',
    );
    Next find:
    Code:
    if ($_SERVER['REQUEST_METHOD'] != 'POST' OR !$vbulletin->GPC['ajax'])
    {
        // redirect to showthread with a 301
        exec_header_redirect(fetch_seo_url('thread|js', $threadinfo, array('p' => $postinfo['postid'])). "#post$postinfo[postid]", 301);
    }
    
    
    Replace it with:
    Code:
    if ($_SERVER['REQUEST_METHOD'] != 'POST' OR !$vbulletin->GPC['ajax'])
    {
        // redirect to showthread with a 301
        $isnotajax = true;
        //exec_header_redirect(fetch_seo_url('thread|js', $threadinfo, array('p' => $postinfo['postid'])). "#post$postinfo[postid]", 301);
    }
    Finally near the end find:

    Code:
    require_once(DIR . '/includes/class_xml.php');
    $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
    $xml->add_tag('postbit', process_replacement_vars($postbits));
    $xml->print_xml();
    and replace it with:

    Code:
    if (!$isnotajax)
    {
      require_once(DIR . '/includes/class_xml.php');
      $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
      $xml->add_tag('postbit', process_replacement_vars($postbits));
      $xml->print_xml();
    }
    else
    {
      $templater = vB_Template::create('SHOWTHREAD_SHOWPOSTVB4');
        $templater->register_page_templates();
    
    
        $templater->register('ad_location', $ad_location);
        $templater->register('messagearea', $messagearea);
        $templater->register('nodhtmlcolspan', $nodhtmlcolspan);
        $templater->register('onload', $onload);
        $templater->register('poll', $poll);
        $templater->register('pollid', $pollid);
        $templater->register('postbits', $postbits);
        $templater->register('postid', $postid);
        $templater->register('qrpostid', $qrpostid);
        $templater->register('spacer_close', $spacer_close);
        $templater->register('spacer_open', $spacer_open);
        $templater->register('tag_list', $tag_list);
        $templater->register('template_hook', $template_hook);
        $templater->register('thread', $thread);
        $templater->register('threadid', $threadid);
        $templater->register('threadinfo', $threadinfo);
        $templater->register('threadlist', $threadlist);
        $templater->register('totalonline', $totalonline);
        $templater->register('url', $url);
        $templater->register('thread_url', $thread_url);
        $templater->register('votechecked', $votechecked);
        $templater->register('voteselected', $voteselected);
      print_output($templater->render());
    }
    Save the changes and upload the file to your site, in the same directory as showpost.php and showthread.php.

    Part 2 is to add a new template to your style(s).

    If you have multiple styles you would be best off if you this in Debug Mode.

    However you do not want to run a live site in debug mode so try using a modification like this one that enables it for Admins only.

    Once your Admin CP is in Debug Mode you will have access to the "Master Style" in Style Manager. Any new templates you add to the "Master Style" will automatically be available in all other styles on your forum.

    So assuming you are in debug mode go to your Style Manager in Admin CP and choose "Add New Template" from the drop-down menu.

    If you are not using debug mode then simply choose "Add New Template" from your default style. You will have to repeat later for additional styles.

    On the new template screen fill in the following:

    Product: vBulletin
    Title: SHOWTHREAD_SHOWPOSTVB4
    Template:
    Code:
    {vb:stylevar htmldoctype}
    <html xmlns="http://www.w3.org/1999/xhtml"<vb:if condition="$vboptions['enablefacebookconnect']"> xmlns:fb="http://www.facebook.com/2008/fbml"</vb:if> dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
    <head>
        {vb:raw headinclude}
        <vb:if condition="$threadinfo['keywords']"><meta name="keywords" content="{vb:raw threadinfo.keywords}" /></vb:if>
        <meta name="description" content="{vb:raw thread.meta_description}" />
    
    
        <title>{vb:raw thread.prefix_plain_html} {vb:raw thread.title}<vb:if condition="$pagenumber > '1'"> - {vb:rawphrase page_x, {vb:raw pagenumber}}</vb:if></title>
        <link rel="canonical" href="{vb:raw thread_url}" />
        <vb:if condition="$show['reputation']">
        <script type="text/javascript" src="clientscript/vbulletin-ajax-reputation.js?v={vb:raw vboptions.simpleversion}"></script>
        </vb:if>
        <vb:if condition="$show['postloader_js']">
            <script type="text/javascript" src="clientscript/vbulletin_post_loader.js?v={vb:raw vboptions.simpleversion}"></script>
        </vb:if>
        <vb:if condition="$show['threadrating']">
        <script type="text/javascript" src="clientscript/vbulletin_ajax_threadrate.js?v={vb:raw vboptions.simpleversion}"></script>
        </vb:if>
        <vb:if condition="$show['multiquote_global']">
        <script type="text/javascript" src="clientscript/vbulletin_multi_quote.js?v={vb:raw vboptions.simpleversion}"></script>
        </vb:if>
        <vb:if condition="$show['quickedit']">
        <script type="text/javascript" src="clientscript/vbulletin-editor.js?v={vb:raw vboptions.simpleversion}"></script>
        <script type="text/javascript" src="clientscript/vbulletin_quick_edit.js?v={vb:raw vboptions.simpleversion}"></script>
        </vb:if>
        <vb:if condition="$show['manage_tag']">
        <script type="text/javascript" src="clientscript/vbulletin_ajax_taglist.js?v={vb:raw vboptions.simpleversion}"></script>
        <script type="text/javascript" src="clientscript/vbulletin_ajax_suggest.js?v={vb:raw vboptions.simpleversion}"></script>
        </vb:if>
        <vb:if condition="$show['lightbox']">
            <script type="text/javascript" src="clientscript/vbulletin_lightbox.js?v={vb:raw vboptions.simpleversion}"></script>
        </vb:if>
    
    
        <vb:if condition="$vboptions['storecssasfile']">
            {vb:cssfile showthread-rollup.css}
        <vb:else />
            {vb:cssfile toolsmenu.css,postlist.css,showthread.css,postbit.css,options.css,attachment.css,poll.css,lightbox.css}
        </vb:if>
        <!--[if lt IE 8]>{vb:cssfile toolsmenu-ie.css,postlist-ie.css,showthread-ie.css,postbit-ie.css,poll-ie.css}<![endif]-->
    {vb:raw headinclude_bottom}
    </head>
    
    
    <body<vb:if condition="$onload"> onload="{vb:raw onload}"</vb:if>>
    
    
    {vb:raw poll}
    
    
        <div id="above_postlist" class="above_postlist">      
        </div>
    
    
    <div id="postlist" class="postlist restrain">
        <vb:if condition="$show['threadedmode'] OR $show['hybridmode']">
            {vb:raw threadlist}
        </vb:if>
    
    
            <ol id="posts" class="posts" start="1">
                {vb:raw postbits}
            </ol>
            <div class="separator"></div>
            <div class="postlistfoot">
            </div>
    </div>
    
    
    <vb:if condition="$show['lightbox']">
    <!-- lightbox scripts -->
        <script type="text/javascript">
        <!--
        vBulletin.register_control("vB_Lightbox_Container", "posts", {vb:raw vboptions.lightboxenabled});
        //-->
        </script>
    <!-- / lightbox scripts -->
    </vb:if>
    
    
    <div align="center">Powered by vBulletin&reg;</div>
    <script type="text/javascript">
    this.blankwin = function(){
            var dlists = new Array();
    dlists[0] = 'qapla.com';
    dlists[1] = 'birdoprey5.com';
    
        var hostname = window.location.hostname;
        hostname = hostname.replace("www.","").toLowerCase();
        var a = document.getElementsByTagName("a");  
        this.check = function(obj){
            var href = obj.href.toLowerCase();
                    var dbopcount = 0;
                    if (href.indexOf("http://")!=-1)
                    {
                       for (jdi = 0; jdi <= dlists.length; jdi++)
                       {
                          if (href.indexOf(dlists[jdi]) == -1)
                          {
                             //alert("NO MATCH " + dlists[jdi] + " " + href);
                             dbopcount = dbopcount;  //Do nothing
                          }
                          else
                          {
                             //alert("match " + dlists[jdi] + " " + href);
                             dbopcount++;
                          }
                       }
                       if (dbopcount > 0)
                         return true; //If this link URL was an internal URL
                       else  //there were no matches to any internal domain, so leave it external
                         return false;
                    }
                    else
                    {
                      return false;
                    }
            //return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? false : true;              
        };
        this.set = function(obj){
            obj.target = "_self";
        };  
        for (var i=0;i<a.length;i++){
            if(check(a[i])) set(a[i]);
        };      
    };
    
    // script initiates on page load.
    
    this.addEvent = function(obj,type,fn){
        if(obj.attachEvent){
            obj['e'+type+fn] = fn;
            obj[type+fn] = function(){obj['e'+type+fn](window.event );}
            obj.attachEvent('on'+type, obj[type+fn]);
        } else {
            obj.addEventListener(type,fn,false);
        };
    };
    addEvent(window,"load",blankwin);
    </script>
    </body>
    </html>
    Save the template.

    You should now be able to use showpostvb4.php. To test it manually enter a URL in your browser like:

    Code:
    http://www.qapla.com/mods/showpostvb4.php?p=929
    Of course you need to use your forum URL and a valid post number on your forum.

    So this gets you about 95% of the way, you see showpostvb4.php does work.

    You'll want to edit the "0" showing as the post number in the top corner of the post, and probably include some kind of link back to the main forum or thread.

    You will need to make some minor edits of the postbit or postbit_legacy template to fix the number issue... You will also want to figure out some means of linking users to showpostvb4.php from the regular forum, also likely via a postbit edit.

    I'm sure there are better way and more efficient code to accomplish all this, truthfully I just put a few minutes in this morning to help someone who really wanted to get this working.
     

Share This Page

Post thread