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
i seem get an error with this mod ... i checked this on my test area and i got the following error ...


Warning: chdir() [function.chdir]: No such file or directory (errno 2) in /home/(removed)/public_html/test/test.php on line 59

Warning: Cannot modify header information - headers already sent by (output started at /home/(removed)/public_html/test/test.php:7) in /home/(removed)/public_html/test/inc/functions.php on line 1216

Warning: Cannot modify header information - headers already sent by (output started at /home/(removed)/public_html/test/test.php:7) in /home/(removed)/public_html/test/inc/functions.php on line 1216

Warning: Cannot modify header information - headers already sent by (output started at /home/(removed)/public_html/test/test.php:7) in /home/(removed)/public_html/test/inc/functions.php on line 1216


(removed) isnt in the error i removed it for security reasons ...
I assume you followed the instructions and changed the "$forumpath" variable to the relative path from wherever this file is, to your forum? (your error seems to suggest not).

<?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('../');
?>
Sorry if this question was already asked, but there are 16 Pages. =S

Is it possible to make the news come out looking like it does on the portal.php? You know how the news is all separated in its own table with avatars, headers, etc. I want that. Big Grin
Yeah, if you style it like that yourself. Just put the bits of information you want, where you want them to be in your layout.

This is the bit you would need to modify:
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 />");
Ok, I almost have it....

So, I put them where they belong, here is what it looks like with the table and what not,

<table cellspacing="1" cellpadding="4" class="tborder">
<tr>
<td class="thead"><strong>&nbsp; echo("<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['subject']}</a></strong></td>
</tr>
<tr>
<td class="trow2" align="right">
<span class="smalltext">Posted: {$date} {$time} by <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a><br />");<!-- start: portal_announcement_numcomments -->
- echo("Replies (<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['replies']}</a>)<br /><hr />"); 

<!-- end: portal_announcement_numcomments --></span>
</td>
</tr>
<tr>
<td class="trow1">
<table border="0" cellpadding="4" width="100%"><tr><td class="trow1" width="1" align="center" valign="top"><img src="{$row2['u.avatar']}"></td><td class="trow1"><p><p style="text-align: center;">
echo("{$message}<br /><br />");
</td></tr>
<tr><td align="right" colspan="2" valign="bottom"><span class="smalltext"><a href="{$forumpath}printthread.php?tid={$row['tid']}\"><img src="http://forums.brisingr.net/images/printable.gif" alt="" /></a>&nbsp;<a href="{$forumpath}sendthread.php?tid={$row['tid']}\"><img src="http://forums.brisingr.net/images/send.gif" alt="" /></a></span></td></tr>
</table>
</td>
</tr>
</table>

I just don't know where and how to impliment it into the code you've already given. =P
In the same place that the code I gave you above was, replace it with this:
echo("<table cellspacing=\"1\" cellpadding=\"4\" class=\"tborder\">
<tr>
<td class=\"thead\"><strong>&nbsp; <a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['subject']}</a></strong></td>
</tr>
<tr>
<td class=\"trow2\" align=\"right\">
<span class=\"smalltext\">Posted: {$date} {$time} by <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a><br />
- Replies (<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['replies']}</a>)<br /><hr />
</span>
</td>
</tr>
<tr>
<td class=\"trow1\">
<table border=\"0\" cellpadding=\"4\" width=\"100%\"><tr><td class=\"trow1\" width=\"1\" align=\"center\" valign=\"top\"><img src=\"{$row2['u.avatar']}\"></td><td class=\"trow1\"><p><p style=\"text-align: center;\">
{$message}<br /><br />
</td></tr>
<tr><td align=\"right\" colspan=\"2\" valign=\"bottom\"><span class=\"smalltext\"><a href=\"{$forumpath}printthread.php?tid={$row['tid']}\"><img src=\"http://forums.brisingr.net/images/printable.gif\" alt=\"\" /></a>&nbsp;<a href=\"{$forumpath}sendthread.php?tid={$row['tid']}\"><img src=\"http://forums.brisingr.net/images/send.gif\" alt=\"\" /></a></span></td></tr>
</table>
</td>
</tr>
</table>");
Thanks a lot. Big Grin

One last problem, I think it's the same as the one posted before, but I'm still not sure what it is =P

The news is coming out fine, but I get this error at the top.
This is the error.

Warning: Cannot modify header information - headers already sent by (output started at /..../public_html/test2.php:5) in /..../public_html/forums/inc/functions.php on line 1216

I'm convinced it's that head part, this is what I have:

<?php $fid = 2; $limit = 5; $forumpath = 'forums/';
chdir('forums'); // path to MyBB
define("IN_MYBB", 1);
require './global.php'; require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
?>

And I know I don't have this,

chdir('../');

Is that it? And if it is, I don;t understand what your instructions are. You say to point it back to where it's being called from? I don't get it. =S

My forums are loacted at, http://brisingr.net/forums
and the page that this code is being used on is, http://brisnigr.net/newstest.php
and the newstest.php is being called up through http://brisingr.net/test2.php through PHP Includes

I don't know if that's needed or not. >.<;;
That wouldn't cause the error but what it does do in ensure that your PHP working directory will be your current directory since unless you change it back to what it was, you'd have a working directory of /forums/ instead of /

It can sometimes cause problems having your working directory not as / (say you included other things in "newstest.php" and found that they weren't showing up, that'd be because PHP was still looking in /forum/ and you files were at /).

Do you have anything else above the block of code you posted? If you'd like, you can PM me the whole lot of code you have (remove anything sensitive that you might not want me to see).
Right, that code you sent me looked fine. But I think I see where the problem is.

saul Wrote:My forums are loacted at, http://brisingr.net/forums
and the page that this code is being used on is, http://brisnigr.net/newstest.php
and the newstest.php is being called up through http://brisingr.net/test2.php through PHP Includes
Including "newstest.php" into "test2.php" after any headers have been parsed will throw that error. It would be best to integrate that code into the file you actually want it in and not include it from somewhere else (or if you do, write it into a function).
Hi,

I've read through the whole topic but I'm not sure if any of the mentioned applies to my problem.

I, too, have character problems. On my site I use hungarian characters which can be: o, ó, ö, ő etc.

Here is how it looks like:

[Image: mybb_www.kepfeltoltes.hu_.gif]

How can I sort this problem out?
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