packyak Posted June 19, 2009 Share Posted June 19, 2009 Hello, i am a complete novice at php, I've been slowly picking bits up as i work with it but i have come to a halt. if you go to this page http://www.packyak.net/default.php you will find a news system that is pulling up news from a PHP forum. basically i am trying to edit the php script to change the layout of what appears on http://www.packyak.net/default.php, i want the "( replies) | " bit to be removed and everything in the second div to be in the first just after the title. so it should all be in the same div table box. The Image below shows how it looks now and how i would like to get it looking i have been snipping the code here and there to try to do just that but i have hit a brick wall. here is my code. <?php // News Plugin // By Tikitiki // Version 1.0.2 // Disallow direct access to this file for security reasons if(!defined("IN_MYBB")) { die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined."); } // Tell MyBB when to run the hooks // $plugins->add_hook("hook name", "function name"); $plugins->add_hook("site_news_plugin_run", "newsplugin_run"); // The information that shows up on the plugin manager // Note that the name of the function before _info, _activate, _deactivate must be the same as the filename before the extension. function newsplugin_info() { return array( "name" => "Site News Plugin", "description" => "Shows news on your site easily through this plugin.", "website" => "http://mods.mybboard.net/view/site-news-plugin", "author" => "Tikitiki", "authorsite" => "http://thetikitiki.com", "version" => "1.0.3", "compatibility" => "14*", "guid" => "a63d9b24e6f8884a6d4f5255a0dd5f0e", ); } // This function runs when the plugin is activated. function newsplugin_activate() { global $db; //DELETE ALL SETTINGS TO AVOID DUPLICATES $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN( 'newsplugin_off', 'newsplugin_fid', 'newsplugin_limit', 'newsplugin_avatar' )"); $db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title IN( 'newsplugin_main', 'news_avatar_bit' )"); $db->delete_query("settinggroups", "name = 'newsplugin'"); $query = $db->simple_select("settinggroups", "COUNT(*) as rows"); $rows = $db->fetch_field($query, "rows"); $insertarray = array( 'gid' => 'NULL', 'name' => 'newsplugin', 'title' => 'Site News Plugin Options', 'description' => 'Options that allow you to configure and personalize Site News Plugin', 'disporder' => $rows+1, 'isdefault' => 0 ); $db->insert_query("settinggroups", $insertarray); $group['gid'] = $db->insert_id(); $insertarray = array( 'name' => 'newsplugin_off', 'title' => 'Switch', 'description' => 'Selecting \\\'off\\\' will turn off the Site News Plugin without having to deactivate it.', 'optionscode' => 'onoff', 'value' => 'on', 'disporder' => 1, 'gid' => $group['gid'] ); $db->insert_query("settings", $insertarray); $insertarray = array( 'name' => 'newsplugin_fid', 'title' => 'News Forum(s)', 'description' => 'The Forums to pull news forum. To use multiple forums seperate it with a comma (,) (ex: 1,2,3).', 'optionscode' => 'text', 'value' => '2', 'disporder' => 2, 'gid' => $group['gid'] ); $db->insert_query("settings", $insertarray); $insertarray = array( 'name' => 'newsplugin_limit', 'title' => 'Number of News Items', 'description' => 'The number of news items to show.', 'optionscode' => 'text', 'value' => '5', 'disporder' => 3, 'gid' => $group['gid'] ); $db->insert_query("settings", $insertarray); //ADD TEMPLATES $news_template_1 = array( "tid" => NULL, "title" => 'newsplugin_main', "template" => $db->escape_string('<div class="box-border"> <div class="box-header"> <a href="{$forumpath}/showthread.php?tid={$news[\'tid\']}">{$news[\'subject\']}(<a href="{$forumpath}/showthread.php?tid={$news[\'tid\']}"></a> on the $date at $time </a> <br />'), "sid" => "-1", "version" => "1.0", "dateline" => TIME_NOW, ); $db->insert_query("templates", $news_template_1); rebuild_settings(); } // This function runs when the plugin is deactivated. function newsplugin_deactivate() { global $db; //DELETE ALL SETTINGS TO AVOID DUPLICATES $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN( 'newsplugin_off', 'newsplugin_fid', 'newsplugin_limit', )"); $db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title IN( 'newsplugin_main', )"); $db->delete_query("settinggroups", "name = 'newsplugin'"); rebuild_settings(); } // This is the function that is run when the hook is called. // It must match the function name you placed when you called add_hook. // You are not just limited to 1 hook per page. You can add as many as you want. function newsplugin_run() { global $db, $mybb, $lang, $templates; if($mybb->settings['newsplugin_off'] != 0) { $forumpath = $mybb->settings['bburl']; require_once MYBB_ROOT."/inc/class_parser.php"; $parser = new postParser(); $fid = ""; if(trim($mybb->settings['newsplugin_limit']) == "") { $limit = ""; } else { $limit = "LIMIT 0, ".intval($mybb->settings['newsplugin_limit']); } if(trim($mybb->settings['newsplugin_fid']) == "") { $fid = 2; } if(strtolower($mybb->settings['newsplugin_fid']) == "all") { $fid = ""; } else if(strstr($mybb->settings['newsplugin_fid'], ',')) { $fids = explode(',', $mybb->settings['newsplugin_fid']); foreach($fids as $key => $forumid) { $fid .= "$comma".intval($forumid); $comma = ","; } $fid = " t.fid IN($fid) AND"; } else { $fid = " t.fid='".intval($mybb->settings['newsplugin_fid'])."' AND"; } $postdata = ""; $query = $db->query(" SELECT t.tid,t.subject,t.uid,t.username,t.dateline FROM ".TABLE_PREFIX."threads t LEFT JOIN ".TABLE_PREFIX."posts p ON (t.tid = p.tid) LEFT JOIN ".TABLE_PREFIX."users u ON (t.uid = u.uid) WHERE$fid t.visible='1' AND t.closed NOT LIKE 'moved|%' AND p.replyto='0' ORDER BY t.tid DESC $limit "); $count = $db->num_rows($query); if($count == 0) { $postdata = "There are no announcements available at this time."; } while($news = $db->fetch_array($query)) { $date = gmdate("jS F Y", $news['dateline']); $time = gmdate("h:i A", $news['dateline']); if($news['avatar'] != "" && $mybb->settings['newsplugin_avatar'] != "no") { if(substr($news['avatar'], 0, 7) != "http://") { $url = $forumpath; $news['avatar'] = str_replace('./', '/', $news['avatar']); } eval("\$avatarbit = \"".$templates->get("news_avatar_bit")."\";"); } else { $avatarbit = ""; } $newsmessage = $parser->parse_message($news['message'], $parser_options); eval("\$postdata .= \"".$templates->get("newsplugin_main")."\";"); } } else { $postdata = "The news is currently not available at this moment."; } echo $postdata; } // End of plugin. ?> Any help/pointers ect ect would be much apriciated as im starting to get a headache! ??? Regards Jonathan[/code] Quote Link to comment Share on other sites More sharing options...
packyak Posted June 19, 2009 Author Share Posted June 19, 2009 Ok so after 2 more hours of trying ive managed to get no further at all, im going to take a break now lol as its driving me insane. I hope somone may be able to save me from any more paracetamol Back in a few hours! Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 20, 2009 Share Posted June 20, 2009 Forgive me if I know nothing about MyBB forum software. You just slapped me a piece of code assuming I know how MyBB works. I only see one part being anything related to the layout of the page and unfortunately, I don't know what to edit to it. I see nothing related to the box-footer. Quote Link to comment Share on other sites More sharing options...
cikitani Posted June 21, 2009 Share Posted June 21, 2009 The code you provided does nothing but fetch. It does not show. Provide the code that displays the HTML so we could help. Quote Link to comment Share on other sites More sharing options...
packyak Posted June 21, 2009 Author Share Posted June 21, 2009 I'm sorry, i relay am a newbie at php and I'm probably well out of my depth. I do apologise for not posting the correct part. this is the page that actually displays the output. <html> <head> <meta http-equiv="Content-Language" content="en-gb"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>PackYak.net</title> <style type="text/css"> a { color: #000000; } a:visited { color: #000000; } a:active { color: #808000; } a:hover { color: #808000; } .box-border { background: #000000); width: 300px; padding: 1px; } .box-header { background: #000000 url(http://www.packyak.co.uk/mainimages/ROCK.jpg); padding: 3px; font-family: Georgia; color: #ffffff; text-align: left; font-size: 10pt; border-bottom: 1px solid #000000; font-weight: bold } .box-header a:link, .box-header a:visited, .box-header a:active { color: #ffffff; text-decoration: none; } .box-header a:hover { color: #ffffff; text-decoration: underline; } .box-footer { background: #000000 url(http://www.packyak.co.uk/mainimages/ROCK.jpg); padding: 3px; padding-right: 5px; font-family: Georgia; color: #ffffff; text-align: right; font-size: 10px; border-top: 1px solid #000000; } .box-footer a:link, .box-footer a:visited, .box-footer a:active { color: #ffffff; text-decoration: none; } .box-footer a:hover { color: #ffffff; text-decoration: underline; } </style> <base target="_blank"> </head> <body style="background-color: #C4BB8E"> <?php define("IN_MYBB", 1); define("KILL_GLOBALS", 1); define("NO_ONLINE", 1); // The Directory to the forum you are using this on. // You do not need a beggining or trailing slash $directory_to_forum = "pyforums"; require dirname(__FILE__)."/".$directory_to_forum."/global.php"; $plugins->run_hooks("site_news_plugin_run"); ?> </body> </html> Is this what you need? Thanks for looking at this for me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.