Announcement

Collapse
No announcement yet.

Having my main site automatically...

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

  • Having my main site automatically...

    I have a news site and I want it to automatically make a new thread in a certain forum on my board whenever I post news on the main site, does anyone know how to do this? I'm currently using vB 2.3.0

    Also, I want to do the same with Reviews and Previews, but i can just take one script and copy it or something

    so any clues?

    MGM out

  • #2
    There are many hacks to do this over at vBulletin.org. vBindex and vbHome (lite) being the main two.
    vBulletin.org Moderator
    The Sisters Three Charmed Discussion Forums

    Comment


    • #3
      yea, but i dont want to use the Portals, I just want to use my scripts and have the script add a thread whenever I make a new news item

      MGM out

      Comment


      • #4
        you might need some one program a script for you :\

        it might be ezier to take a look at the portals and figureout how to just make it display the news end :\

        Comment


        • #5
          I set up my board to do the opposite. I have a "news" forum where only I can start new threads. I wrote the homepage of my site so that it pulls in the the first post from the 4 most recent news threads onton my front page. Take a look here: http://www.improvresourcecenter.com/

          It's great, because it turns vbulletin itself into your back end.

          Comment


          • #6
            thats what most the portals do

            Comment


            • #7
              What's the fun of using a portal when you can write the php yourself

              Comment


              • #8
                i wish i could write php my self

                Comment


                • #9
                  demo can be seen at my site (http://www.strategy-x.com) have this on your index.php file:
                  PHP Code:
                  include('news.php');
                  $currentnews=$DB_site->query("SELECT*FROM thread WHERE forumid='8' ORDER BY threadid DESC LIMIT 0,5");
                   while(
                  $news=$DB_site->fetch_array($currentnews)){


                     
                  $pagetext=$DB_site->query("SELECT pagetext FROM post WHERE threadid='$news[threadid]'");
                   
                  $pagetext=$DB_site->fetch_array($pagetext);
                    
                  $pagetext[pagetext]=nl2br($pagetext[pagetext]);

                  news();
                   } 
                  and create a file called news.php:
                  PHP Code:
                  chdir("forums"); //change this
                  include("./global.php");

                  function 
                  news(){
                   global 
                  $DB_site,$news,$pagetext,$currentnews;
                              if(
                  $news[open]=='1'){
                     
                  $ts="open";
                     }else{
                       
                  $ts="closed";
                       }
                   
                  $template='<table border="1" cellspacing="0" style="border-collapse: collapse" width="90%" cellpadding="3" id="AutoNumber4" bordercolor="#000000">
                  <tr>
                  <td width="100%" background="images/bar.gif">
                  <p align="left"><font class="headertext">$news[title]</font></td>
                  </tr>
                  <tr>
                  <td width="100%" bgcolor="#333333" valign="top"><p align="left">$pagetext[pagetext]</p></td>
                  </tr>
                   </table>
                   <table border="0" width="90%" cellspacing="0" cellpadding="3">
                   <tr>
                   <td width="50%" valign="top">
                   <p align="left">
                   Posted By: $news[postusername] | $news[replycount] comments</td>
                   <td width="50%" valign="top">
                   <p align="right">
                   views $news[views] | thread is <b>$ts</b>
                   </td>
                   </tr>
                   </table>
                   <br>'
                  ;

                   
                  $template=trim($template);
                   eval(
                  "\$template= \"".addslashes($template)."\";");
                   
                  //echo("$template");
                   
                  return $template;
                   } 
                  just edit the HTML

                  Comment


                  • #10
                    hey thanks!! Ill try that code out right away

                    would i be able to do the same thing for, say, a reviews and previews page?

                    I know how to code PHP, it's just that im trying to understand vB's MySQL layout and how I can pull info out of it or put info into it via my own files

                    EDIT: Hey Clive, your code didn't work =/ IM me via AIM if you wanna see how I set it up, but it didn't work

                    MGM out
                    Last edited by MetalGearMaster; Thu 4 Sep '03, 4:47pm.

                    Comment


                    • #11
                      Moderators and Developers: I realise this is close to hacking, but im just trying to help this guy! Feel free to remove the script if its really that much of a problem.

                      My news script:
                      PHP Code:
                      // ######################### REQUIRE BACK-END ############################
                      require_once('./global.php');
                      require_once(
                      './includes/functions_postbit.php');

                        
                      $getnews $DB_site->query("
                         SELECT thread.* , post.*, user.username AS uname,
                         IF(user.displaygroupid=0, user.usergroupid, user.displaygroupid) AS displaygroupid
                         FROM `thread` 
                         LEFT JOIN `post` ON ( thread.firstpostid = post.postid ) 
                         LEFT JOIN `user` ON ( post.userid = user.userid )
                         WHERE thread.forumid IN(" 
                      $vboptions['newsforums'] . ")
                         ORDER BY thread.dateline DESC 
                         LIMIT " 
                      $vboptions['newspostlimit']);
                         
                      $newsbits '';

                        while (
                      $newsitem $DB_site->fetch_array($getnews))
                        {
                         
                      $newsitem['musername'] = fetch_musername($newsitem);
                         
                      $newsbits .= construct_postbit($newsitem'frontnewshome_bit''newshome');
                        }
                        
                      $DB_site->free_result($getnews);

                       eval(
                      'print_output("' fetch_template('FRONTNEWSHOME') . '");'); 
                      There is extra code up the top that initializes the vBulletin caches for templates instead of needing lots of queries.

                      I created 2 templates, FRONTNEWSHOME and frontnewshome_bit which contain design information.

                      FRONTNEWSHOME contains similar content to a FORUMHOME or SHOWTHREAD template. frontnewshome_bit contains the design for each news item.

                      I then also created a custom option (using debug mode) called newsforum which you set in the options area of the forumid which news is contained in. Post an thread in that forum and it becomes news.

                      And because im really nice, here are my templates

                      FRONTNEWSHOME:
                      Code:
                      $stylevar[htmldoctype]
                      <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
                      <head>
                       <!-- no cache headers -->
                       <meta http-equiv="Pragma" content="no-cache" />
                       <meta http-equiv="Expires" content="-1" />
                       <meta http-equiv="Cache-Control" content="no-cache" />
                       <!-- end no cache headers -->
                       <title>$vboptions[bbtitle]</title>
                       $headinclude
                      </head>
                      <body>
                      $header
                      
                      <!-- main -->
                      $newsbits
                      <!-- /main -->
                      
                      <br />
                      
                      <!-- timezone -->
                      <table cellpadding="2" cellspacing="0" border="0" width="$stylevar[tablewidth]" align="center">
                      <tr valign="bottom">
                       <td class="smallfont" align="right"><span class="smallfont">All times are GMT$timediff. The time now is <span class="time">$timenow</span>.</span></td>
                      </tr>
                      </table>
                      <!-- /timezone -->
                      
                      $footer
                      </body>
                      </html>
                      frontnewshome_bit:
                      Code:
                      <table cellpadding="$stylevar[outerborderwidth]" cellspacing="0" border="0" class="tborder" width="$stylevar[tablewidth]" align="center"><tr><td>
                      <table cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%">
                      <tr align="center">
                        <td class="thead" width="100%" align="left"><span class="largefont"><b>$post[title]</b></span><br><span class="smallfont">$post[musername] - <span class="time">$post[postdate]<if condition="$vboptions['yestoday'] != 2">, $post[posttime]</if>$post[firstnewinsert]</span></span></td>
                        <td class="thead" nowrap="nowrap" class="smallfont" valign="bottom">
                         <if condition="$post[replycount] > 1"><a href="showthread.php?t=$post[threadid]">$post[replycount] comments</a></if>
                         <if condition="$post[replycount] == 1"><a href="showthread.php?t=$post[threadid]">$post[replycount] comment</a></if>
                         <if condition="$post[replycount] == 0"><a href="newreply.php?p=$post[postid]">no comments</a></if>
                        </td>
                        
                      </tr>
                      
                      <tr>
                       <td class="page" colspan="2">
                       <p>$post[message]</p>
                       <if condition="$post[thumbnail]">
                        <span class="smallfont">$post[username] has attached the following image(s):</span><br />
                        $post[thumbnail]<br />
                       </if>
                       <if condition="$post[attachment]">
                        <if condition="$post[thumbnail]"><br /><span class="smallfont">$post[username] has attached these file(s):</span><br /></if>
                        $post[attachment]<br />
                       </if>
                       </td>
                      </tr>
                      </table>
                      </td></tr></table><br>

                      Comment


                      • #12
                        Eeep - i just noticed something.

                        The script that i posted has actually been improved to use existing postbit functions that might not work without hacking functions_postbit.php.

                        Im pretty sure it will be okay, if worst comes to worst, in my code:

                        Change
                        PHP Code:
                        construct_postbit($newsitem'frontnewshome_bit''newshome'); 
                        To
                        PHP Code:
                        construct_postbit($newsitem'frontnewshome_bit'); 

                        Comment


                        • #13
                          Merk, I have no idea how to set yours up

                          is it a new php file? where do it put it? my index or the forums directory? and why the heck does it require includes/function_postbit.php!!??

                          developers, sorry if this is a hacking thing, I didnt know where else to ask it besides the PHP forum =/, i guess i could ask at vb.org but these peeps seem to be helpful, hope ya dont mind

                          MGM out

                          Comment


                          • #14
                            You place the code into a new file, (i called it index.php and renamed index.php from vbulletin to forumhome.php).

                            It includes functions_postbit.php because construct_postbit is easier to use than re-write the necessary function to parse each post (considering it is a post..)

                            So if you make news.php and fill it with the php code, and add those templates to your styles, it will work.

                            just updated the php so its a bit easier to use for you, added the cache stuff too

                            You only need to add templates, you dont need to modify the vBulletin options area for this modified script

                            PHP Code:
                            <?php
                            // ####################### SET PHP ENVIRONMENT ###########################
                            error_reporting(E_ALL & ~E_NOTICE);
                            // #################### DEFINE IMPORTANT CONSTANTS #######################
                            define('NO_REGISTER_GLOBALS'1);
                            define('THIS_SCRIPT''index');
                            define('NEWS_CUT'10); // HOW MANY NEWS ITEMS TO SHOW ON A PAGE
                            define('NEWS_FORUM'5); // THE FORUMID OF THE NEWS FORUM
                            // ################### PRE-CACHE TEMPLATES AND DATA ######################
                            // get special phrase groups
                            $phrasegroups = array();
                            // get special data templates from the datastore
                            $specialtemplates = array();
                            // pre-cache templates used by all actions
                            $globaltemplates = array( 'FRONTNEWSHOME''frontnewshome_bit''postbit_buttons''postbit_offline''postbit_userinfo' );
                            // pre-cache templates used by specific actions
                            $actiontemplates = array();
                            // ######################### REQUIRE BACK-END ############################
                            require_once('./global.php');
                            require_once(
                            './includes/functions_postbit.php');
                              
                            $getnews $DB_site->query("
                               SELECT thread.* , post.*, user.username AS uname,
                               IF(user.displaygroupid=0, user.usergroupid, user.displaygroupid) AS displaygroupid
                               FROM `thread` 
                               LEFT JOIN `post` ON ( thread.firstpostid = post.postid ) 
                               LEFT JOIN `user` ON ( post.userid = user.userid )
                               WHERE thread.forumid IN(" 
                            NEWS_FORUM ")
                               ORDER BY thread.dateline DESC 
                               LIMIT " 
                            NEWS_CUT);
                              
                            $newsbits '';
                              while (
                            $newsitem $DB_site->fetch_array($getnews))
                              {
                               
                            $newsitem['musername'] = fetch_musername($newsitem);
                               
                            $newsbits .= construct_postbit($newsitem'frontnewshome_bit''newshome');
                              }
                              
                            $DB_site->free_result($getnews);
                             eval(
                            'print_output("' fetch_template('FRONTNEWSHOME') . '");');
                            ?>

                            Comment


                            • #15
                              well, the way i have it setup is my board is locared in a /forums directory, when i try to use any of the scripts above and have it on my index directory, it's just a blank page, but when i use some of them in the /forums directory they work.

                              But that's a problem though, how will peeps see it if my website is pointing to the index and not the forums directory??

                              EDIT: hey merk, your script just gives me a blank page when i run it... any clue whats wrong?

                              MGM out
                              Last edited by MetalGearMaster; Sat 6 Sep '03, 8:32am.

                              Comment

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