Announcement

Collapse
No announcement yet.

Integration with existing site (plugins/hooks)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integration with existing site (plugins/hooks)

    I currently operate a website that is built around phpbb3, and one of the key things I had planned to do with it was embed non-forum data about each user into the side (or top) author section of each post. One thing I wanted to know before making a decision to switch to vBulletin is how difficult this might be using the hooks/plugin system vb utilizes.

    More specifically, I operate a site that hosts several games, and its user system is shared with the one phpbb3 uses - I'm a programmer so it wasn't that hard to tie them together. I would prefer that along with a user's avatar, total posts, user rank, etc. I could display info about their game activity above (or to the side) of each post. If I could, for instance, develop a plugin that takes each poser's id in a thread view, grabs data from non-forum tables, and then embeds it into the view-post template, that would be a huge bonus to vBulletin.

  • #2
    For placing things within a post, you can try out the admin demo. You can use HTML and whatnot to test out whatever you'd like to do. The template is postbit.

    It's not that hard to make plugins/hooks and external/new vBulletin pages. It's all fairly simple. It's just php code that was eval()'d to parse.

    Comment


    • #3
      So are you saying you can place php code directly into a template?

      For example, I could put the php code (actually pseudo-code) below into the postbit template:

      PHP Code:
      <?php
      $query 
      "SELECT something FROM non-Vb-table WHERE userID = $vB_poster_id";
      $result db_query($query);

      list(
      $some_data) = db_fetch_row($result);
      echo 
      "$some_data";
      ?>

      Comment


      • #4
        You cannot put it in the postbit template. (Without a modification to do so, that is.)
        You'll have to go over to vBulletin.org and find the plugin to allow php in templates. Note: Doing so may be a security risk, should you be vulnerable and a hacker gets in, or one of your admins wanting to do something malicious. (just as dangerous as granting plugin privs, though)

        I would suggest using a plugin, and placing the variable in the template for those security reasons.

        Oh, and it's $vbulletin->query_read() for SELECT's

        Comment


        • #5
          Thanks, SNN. I, too, would prefer to keep such additions isolated to a plugin. I think I just misread your first reply about code in the templates.

          One last question I have concerning the integration is whether it's easy/difficult to maintain user sessions across pages outside the forum. For example, with phpbb3, all I had to do was include a php script from the forum directory at the beginning of all non-forum pages and call a few functions to check for and load the data of the user if he/she was logged into the forums. This code looks like below:

          PHP Code:
          include($phpbb_root_path 'common.php');

          $user->session_begin();
          $auth->acl($user->data);
          $user->setup('ucp'); 
          Can you tell me if there's anything like above to continue vB user sessions outside of the forum? Thanks again.

          Comment


          • #6
            There is example code at vBulletin.org to "stay logged in" to vBulletin and thus have all that user info available on non-vBulletin pages.

            You can write plugins for vBulletin which read that other table based on userid and inject the data into a new variable which you can then insert into tables.

            Keep in mind if these "extra information" are just extra profile fields like favorite car, favorite movie, favorite color type stuff then vBulletin allows virtually unlimited Custom User Profile Fields. So you might set up vBulletin, create your extra profile fields, and then do a SQL merge of that data into the new fields in the vBulletin database. It will be a fun SQL query to write, but then you don't have to have to do plugins/modifications.

            Profile Fields can also be invisible, and you can write template conditionals for them. So if you have some subscriber or other hidden information about each user, you could view it in the control panel and also do special things in the page templates based on the contents of those hidden fields.

            Comment


            • #7
              Originally posted by feldon23 View Post
              There is example code at vBulletin.org to "stay logged in" to vBulletin and thus have all that user info available on non-vBulletin pages.
              This is what I needed to know. I was almost certain there had to be some way to do it (most modern forum packages do), but I needed to verify.

              Custom profile fields are great for the examples you listed, but they wouldn't work for my site's needs. Most of the data is one-to-many relationship, where a user would - for instance - have characters on multiple hosted games, etc. Therefore, I'll just write a plugin to handle all that. Shouldn't be too hard to just grab all the data from non-forum tables I want to display on postbit, load it into a single variable, then insert the variable onto that postbit template.

              Thanks for all your help.

              One thing I've heard is that vBulletin is pretty difficult to upgrade because it often conflicts with customized styles/templates. Is this true?

              Comment


              • #8
                If you make a lot of changes to the HTML in your templates, then upgrading can be tricky as you have to do a comparison. There is a built-in template comparison utility which helps.

                vBulletin 3.7 has template hooks which is just a weird way of saying that throughout the templates, there are some PHP variables which you can populate from the outside. For instance the header template has something like $banners[top_ad_html]. The navigation bar as some places where it does something like $navbar[leftside] and $navbar[userlinks] and $navbar[rightside]. So you can write a Plugin which populates those variables and then you are avoiding having to maintain that template each time they come out with a new version of vB.

                I know it seems kind of backwards that by adding PHP, you are actually making your life easier upgrading, but template hooks are pretty cool like that.

                I do keep a list of templates I change and really try to keep the number of edits to a minimum because I know I will have to come back later. At least we don't have to hack up PHP files anymore like phpBB. vBulletin has something like 900 "hooks" where you can execute PHP code by writing a Plugin without editing the original PHP file.

                Hooks are not nearly as well documented as they should be, but if you poke around the PHP files and look for the hooks, you can usually figure out what variables and functions are available to you at that point in the code and then figure out how to do what you want based on that.

                Comment

                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                Working...
                X