Hello,
I've been developing a new plugin for MyBB 1.4 and I seem to have hit a roadblock.
I wanted to remove all styling and header/footer items from the
announcements.php pages on the forum. I opened up the
announcement template and found this:
<html>
<head>
<title>{$lang->announcements}</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both; border-bottom-width: 0;">
<tr>
<td class="thead" colspan="3"><strong>{$lang->forum_announcement}</strong></td>
</tr>
</table>
{$announcement}
{$footer}
</body>
</html>
So, I simply replaced it with this:
{$announcement}
I was dismayed to see that even after I altered the template, the announcements still had postbit_classic styles attached to them:
[attachment=10622]
I only want the announcement message to display when someone visits an
announcements.php page. I do not want the postbit buttons, border, background or tables to be used.
I looked around
announcements.php and
/inc/functions_post.php, but could not find anything myself.
How do I remove the postbit layout from the annoucements?
I'm sure I have overlooked something simple, but for the life of me I just can't figure it out.
Thanks for any help, I greatly appreciate it!
If you're developing a plugin, the simplest thing would probably to write your own announcements.php page, since all you want is the message.
Something like this I suppose:
define('IN_MYBB', 1);
require './global.php';
require_once MYBB_ROOT.'inc/class_parser.php';
$parser = new postParser;
$aid = intval($mybb->input['aid']);
$ann = $db->fetch_array($db->simple_simple('announcements', '*', 'aid='.$aid));
if(!$ann)
error('Invalid announcement'); // use the correct langvar here if you wish
// set the parser options here appropriately
$options = array();
$message = $parser->parse_message($ann['message'], $options);
echo $message;
(2008-08-19, 07:22 AM)ZiNgA BuRgA Wrote: [ -> ]If you're developing a plugin, the simplest thing would probably to write your own announcements.php page, since all you want is the message.
Something like this I suppose:
define('IN_MYBB', 1);
require './global.php';
require_once MYBB_ROOT.'inc/class_parser.php';
$parser = new postParser;
$aid = intval($mybb->input['aid']);
$ann = $db->fetch_array($db->simple_simple('announcements', '*', 'aid='.$aid));
if(!$ann)
error('Invalid announcement'); // use the correct langvar here if you wish
// set the parser options here appropriately
$options = array();
$message = $parser->parse_message($ann['message'], $options);
echo $message;
Thanks, I'll try this out.
Hmm...I seem to be having a bit more problems with the new announcement page you suggest I create.
I created a new "announcements" page that is called information.php. Inside, I have the following PHP code:
<?php
phpdefine('IN_MYBB', 1);
require './global.php';
require_once MYBB_ROOT.'inc/class_parser.php';
$parser = new postParser;
$aid = intval($mybb->input['aid']);
$ann = $db->fetch_array($db->simple_simple('announcements', '*', 'aid='.$aid));
if(!$ann)
error('Invalid announcement'); // use the correct langvar here if you wish
// set the parser options here appropriately
$options = array();
$message = $parser->parse_message($ann['message'], $options);
echo $message;
?>
When I visit the information.php?aid=9 page in my browser, I get the following error:
Quote:Fatal error: Call to undefined function: simple_simple() in */*/public_html/information.php on line 8
Line 8 of the information.php is:
$ann = $db->fetch_array($db->simple_simple('announcements', '*', 'aid='.$aid));
I don't understand the simple_simply part of code on this line. Is this a new development in MyBB, or is it a coding mistake?
What do I need to do in order to get this new information.php page to function correctly?
Thanks again for your help, I really appreciate it!
(2008-08-20, 06:49 PM)Kodaks Wrote: [ -> ]I don't understand the simple_simply part of code on this line. Is this a new development in MyBB, or is it a coding mistake?
It's just a typo, it should be simple_select. :p
Shouldn't simple_simple be simple_select?
(2008-08-20, 09:17 PM)WDZ Wrote: [ -> ] (2008-08-20, 06:49 PM)Kodaks Wrote: [ -> ]I don't understand the simple_simply part of code on this line. Is this a new development in MyBB, or is it a coding mistake?
It's just a typo, it should be simple_select. :p
(2008-08-20, 09:21 PM)labrocca Wrote: [ -> ]Shouldn't simple_simple be simple_select?
I understand it was a typo, but didn't used to have something else included in those kinds of lines for this type of function to work? Was there some kind of change with this new version?
You could store the query result resource in a temporary variable like this, but ZiNgA BuRgA made his code a bit more compact.
$query = $db->simple_select('announcements', '*', 'aid='.$aid);
$ann = $db->fetch_array($query);
The only change I can think of in 1.4 is that you don't need to use TABLE_PREFIX anymore.
Quote:The only change I can think of in 1.4 is that you don't need to use TABLE_PREFIX anymore.
Ahhh...thats what I was thinking of!
After I changed the simple_simple to simple_select, but now I am experiencing a different error message. Here is the error:
Quote:Fatal error: Call to undefined function: phpdefine() in */*/public_html/information.php on line 2
Again, here is the code I am using for information.php:
<?php
phpdefine('IN_MYBB', 1);
require './global.php';
require_once MYBB_ROOT.'inc/class_parser.php';
$parser = new postParser;
$aid = intval($mybb->input['aid']);
$ann = $db->fetch_array($db->simple_select('announcements', '*', 'aid='.$aid));
if(!$ann)
error('Invalid announcement'); // use the correct langvar here if you wish
// set the parser options here appropriately
$options = array();
$message = $parser->parse_message($ann['message'], $options);
echo $message;
?>
It seems to me that I am missing the code where it instructs the script to retrieve the applicable announcements from the MySQL database. I tried adding that part it, but to no avail. Any ideas?
Thanks again!