Trouble making postbit a user option

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ewbarnard
    Member
    • Nov 2004
    • 79
    • 3.0.3

    Trouble making postbit a user option

    I hopefully followed the instructions here:



    But the thread display doesn't change. My phpinclude_start has:
    PHP Code:
    // Example of how to include a separate file:
    // ob_start();
    // require("yourheader.html");
    // $header = ob_get_contents();
    // ob_end_clean();
    if ($bbuserinfo['field5'] == 'Top')
      {
        
    $vboptions['legacypostbit'] = 0;
      }
    else
      {
        
    $vboptions['legacypostbit'] = 1;
      } 
    I added the else clause to make double-sure, because it wasn't working

    I added this as debug code to SHOWTHREAD:
    Code:
    <!-- debug
    field5 $bbuserinfo[field5]
    legacypostbit $vboptions[legacypostbit]
    /debug -->
    
    <div id="posts">$postbits</div>
    and my page source shows:

    Code:
    <!-- debug
    field5 Top
    legacypostbit 0
    /debug -->
    
    <div id="posts"><!-- BEGIN TEMPLATE: postbit -->
    but the thread displays with the avatar to the left, in legacy form. I do have legacy set as the way to go in the admin control panel.

    Thanks as always,

    Ed
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    Nothing immediately comes to mind. I sent Wayne a PM about this.

    Comment

    • ewbarnard
      Member
      • Nov 2004
      • 79
      • 3.0.3

      #3
      Looks like it's cached.

      Deciding to get over my insufferable laziness, I grepped around the code and find the only references in includes/functions.php. I find an interesting comment here:

      PHP Code:
      // ###################### Start gettemplate #######################
      function fetch_template($templatename$escape 0$gethtmlcomments 1)
      {
          
      // gets a template from the db or from the local cache
          
      global $templatecache$DB_site$vboptions$style;
          global 
      $tempusagecache$templateassoc;

          
      // use legacy postbit if necessary
          
      if ($vboptions['legacypostbit'] AND $templatename == 'postbit')
          {
              
      $templatename 'postbit_legacy';
          } 
      I havn't traced further into the code as yet, but could that be the problem, i.e., because the template gets cached, the distinction is ignored?

      Thanks as always!

      Comment

      • ewbarnard
        Member
        • Nov 2004
        • 79
        • 3.0.3

        #4
        Code needs to be in global.php.

        It works now.

        I had to move the initialization code from phpinclude_start to global.php, because the templates now get cached BEFORE phpinclude_start gets called.

        I'm not sure I'd call this a bug.

        It's a close call as to whether you want to do the phrase (and template) initialization prior to phpinclude_start, or after. Perhaps the answer is to create one or more hooks (user exits, such as phpinclude_start) at earlier points in the initialization. Assuming, that is, that the preference is to keep users like me out of the code. Editing global.php is easy enough, but at the rate I'm going, I cringe at thoughts of the next version upgrade

        You'll want to update the "how to" thread, to move the initialization into global.php.

        Thanks, as always, for the help and ideas!

        Ed

        Comment

        • ewbarnard
          Member
          • Nov 2004
          • 79
          • 3.0.3

          #5
          Originally posted by Jake Bunce
          Nothing immediately comes to mind. I sent Wayne a PM about this.
          Jake, is the changed initialization a bug I should report, or a feature? I'm bumping this because we probably want to update Wayne's thread explaining the hack

          Comment

          • Jake Bunce
            Senior Member
            • Dec 2000
            • 46598
            • 3.6.x

            #6
            Originally posted by ewbarnard
            Jake, is the changed initialization a bug I should report, or a feature?
            If it's a feature, I am not familiar with it. It doesn't hurt to post a bug report. The devs will look at your report and tell you one way or the other.

            Comment

            Loading...
            Working...