MyBB Community Forums

Full Version: Displaying News on your homepage
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
Well it uses the database of the forum to get the info, so unless you can remotely access the other forums database, then no. Even if you could do that (and I have no idea if you can), it currently relies on the MyBB core to handle the database connection, so you would need to do all that yourself.
Simple question is there a way I can do this but using SSI? As I configurationed apache to handle .shtml files as .portal and I wish to use .portal instead as I know you can include a PHP file in SSI
Exactly how do you mix youre top info and another one? These two:

<?php

    $fid = 2;
    $limit = 5;
    $forumpath = 'forum/';

    chdir($forumpath);
    define("IN_MYBB", 1);
    require('./global.php');
    require_once MYBB_ROOT."inc/class_parser.php";
    $parser = new postParser;
    chdir('../');
?>

<?php
chdir('forums'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
?>
(2009-09-27, 02:26 AM)wubaz Wrote: [ -> ]Exactly how do you mix youre top info and another one? These two:

It may well be because it is 3:30AM here, but I don't understand your question at all.
I built my site with wordpress. I haven't figured out how to use the user login from my forum inplace of the word press one so I decided to try this code out for the sake of posting news through forums and not wordpress. I run 1.4.8 with the latest patch. I read all 30 pages to figure out what I'm doing wrong and it's aggravating >.< I keep getting this error on the index page

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/xxxx/public_html/wp-content/themes/stargazer/index.php on line 37

This is the code of the page I want the news to appear on
<?php

    $fid = 13;
    $limit = 5;
    $forumpath = 'forums/';

    chdir('forums/');
    define("IN_MYBB", 1);
    require('./global.php');
    require_once MYBB_ROOT."inc/class_parser.php";
    $parser = new postParser;
    chdir('../');
?>

<?php get_header(); ?>

<div id="content">

<?php
    
    $query = $db->simple_select('threads', '*', "fid='{$fid}' ORDER BY tid DESC LIMIT {$limit}");
    if($db->num_rows($query) > 0)
    {
        while($row = $db->fetch_array($query))
        {
            $query2 = $db->simple_select('posts', '*', "pid='{$row['firstpost']}'");
            $row2 = $db->fetch_array($query2);
            
            $date = my_date($mybb->settings['dateformat'], $row2['dateline'], "", 1);
            $time = my_date($mybb->settings['timeformat'], $row2['dateline'], "", 1);

            $options = array(
                            'allow_html' => 'yes', 
                            'filter_badwords' => 'yes', 
                            'allow_mycode' => 'yes', 
                            'allow_imgcode' => '1' 
                            'allow_smilies' => 'yes', 
                            'nl2br' => 'yes', 
                            'me_username' => 'yes'
                            );
            $message = $parser->parse_message($row2['message'], $options);
            
            echo("<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['subject']}</a> - 
                Posted: {$date} {$time} by <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a><br />");
            echo("{$message}<br /><br />");
            echo("Replies (<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['replies']}</a>)<br /><hr />");
        }
    }
    else
    {
        echo 'Nothing to display.';
    }

?>

<?php if (have_posts()) : ?>

	<?php while (have_posts()) : the_post(); ?>

		<div class="post" id="post-<?php the_ID(); ?>">
			<h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

			<div class="entry">
				<?php the_content('Read the rest of this entry &raquo;'); ?>
			</div>

			<p class="meta">
				<span class="posted">Posted by <?php the_author_posts_link() ?> on <?php the_time('F jS, Y') ?></span>
				
				<?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'comments'); ?>
			</p>

		</div>

	<?php endwhile; ?>

	<div class="navigation">
		<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
		<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
	</div>

<?php else : ?>

	<h2 class="center">Not Found</h2>
	<p class="center">Sorry, but you are looking for something that isn't here.</p>
	<?php include (TEMPLATEPATH . "/searchform.php"); ?>

<?php endif; ?>

</div>
<!-- end #content -->

<?php get_sidebar(); ?>

<?php get_footer(); ?>
Should mention, I'm a noob at making websites. This is my first one >.>
I'm receiving a MyBB error:
http://seithu.uppload.com/
(2009-09-27, 07:47 PM)Seithu Wrote: [ -> ]I'm receiving a MyBB error:
http://seithu.uppload.com/

You need to remove any "TABLE_PREFIX." (minus the quotes) from the code from the first page. The code was for 1.2, not 1.4 so it needs a bit of updating when it is used with 1.4.
MrD. is there a way to use this PHP code inside a SSI?
I have absolutely no idea, I have never used SSI. Sorry.

Out of curiosity, is that a happy Taiga in your avatar?
Nop its not Taiga ^^

One more question MrD. i got the script to work and I am back to PHP I have the script working but I have few questions.

1-I have the code to limit how much text can show but I dont wont a post to end at "wat" this is an example of word "watch" getting cut off do to limit how can I make it show wat"..." have ... as I sticked Read Full Article link so thats not a problem.

2- How can I make http://www.mysite.com/?page=2 this is for showing older news.
3- What line of code can I use to show news under http://www.mysite.com/?news ????

-Thanks
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33