2011-08-07, 10:35 PM
Hello, I have a problem, and I can't seem to find a way how to fix this. The situation is as follows:
I'm currently developing a custom index page, which users will arrive at when they visit the forum. I've made the page based on the original index.php file which is more or less intact (removed some unnecessary code like stats, birthdays etc which won't be showing on the page). I also have the custom template for it, basically I kept the header and welcome box, but I removed everything below like forum listing etc. That's all fine, and it looks good.
Now I want to use my "news script", which I got from this forum a few years back and has been used on my website. With this script I want to show certain topics from specific forums on this new custom index page. I've tried everything I could think of to get this script going, but I keep getting errors, like:
The original script is as follows:
But some things are not correct, so I have been changing a few things. Some things are already being defined in the customindex.php file, other definitions are not needed when running the script in the forum folder instead of the website root (which the script is originally made for).
But still I get the same error. I tried adding this code to the template. Adding only the first part to the index file and the second part to the template etc. etc. Somewhere I'm doing something completely wrong, but I don't know why. Basically I want to make two columns which show the first posts of different specific forum(s). Like one column with announcements from in example fid 1, 4 and 7. And on column with announcements from in example fid 22 and 77. It's basically a completely customized/revamped portal kind of page.
Any help much much appreciated!
I'm currently developing a custom index page, which users will arrive at when they visit the forum. I've made the page based on the original index.php file which is more or less intact (removed some unnecessary code like stats, birthdays etc which won't be showing on the page). I also have the custom template for it, basically I kept the header and welcome box, but I removed everything below like forum listing etc. That's all fine, and it looks good.
Now I want to use my "news script", which I got from this forum a few years back and has been used on my website. With this script I want to show certain topics from specific forums on this new custom index page. I've tried everything I could think of to get this script going, but I keep getting errors, like:
Quote:Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/manne/public_html/forum_ontwikkel/index_tdnl.php(166) : eval()'d code on line 34
The original script is as follows:
<?php
$fid = 2;
$limit = 12;
$forumpath = 'forum/';
chdir($forumpath);
define("IN_MYBB", 1);
require('./global.php');
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
chdir('../');
?>
<?php
$query = $db->simple_select('threads', '*', "fid='2' OR fid='122' 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' => '1',
'filter_badwords' => '1',
'allow_mycode' => '1',
'allow_smilies' => '1',
'nl2br' => '1',
'me_username' => '1'
);
$message = $parser->parse_message($row2['message'], $options);
echo("<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['subject']}</a><<br>
Door <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a> op {$date} om {$time}");
}
}
else
{
echo 'Nothing to display.';
}
?>
But some things are not correct, so I have been changing a few things. Some things are already being defined in the customindex.php file, other definitions are not needed when running the script in the forum folder instead of the website root (which the script is originally made for).
[code]
<?php
$fid = 2;
$limit = 12;
?>
<?php
$query = $db->simple_select('threads', '*', "fid='2' OR fid='122' 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' => '1',
'filter_badwords' => '1',
'allow_mycode' => '1',
'allow_smilies' => '1',
'nl2br' => '1',
'me_username' => '1'
);
$message = $parser->parse_message($row2['message'], $options);
echo("<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['subject']}</a><<br>
Door <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a> op {$date} om {$time}");
}
}
else
{
echo 'Nothing to display.';
}
?>
But still I get the same error. I tried adding this code to the template. Adding only the first part to the index file and the second part to the template etc. etc. Somewhere I'm doing something completely wrong, but I don't know why. Basically I want to make two columns which show the first posts of different specific forum(s). Like one column with announcements from in example fid 1, 4 and 7. And on column with announcements from in example fid 22 and 77. It's basically a completely customized/revamped portal kind of page.
Any help much much appreciated!