recent discussions-How to
hi everyone!
new to vanilla!
i have a question.
is there a way to put a block of the recent discusions into my home page?which is wordpress.
like http://www.cssbeauty.com/ has at the bottom and other sites.and how.
thanks a lot
0
This discussion has been closed.
Comments
<?php if(!defined('VANILLA_DIR')) define('VANILLA_DIR', './'); include(VANILLA_DIR.'appg/settings.php'); include(VANILLA_DIR.'appg/init_ajax.php'); function GetRecentDiscussions($Limit = 10) { $DiscFields = &$GLOBALS['DatabaseColumns']['Discussion']; $Data = $GLOBALS['Context']->Database->Execute( 'select t.'.$DiscFields['DiscussionID'].', t.'.$DiscFields['Name'].' from '.$GLOBALS['Configuration']['DATABASE_TABLE_PREFIX']. $GLOBALS['DatabaseTables']['Discussion'].' t where t.'.$DiscFields['Active'].' = \'1\' and ( t.'.$DiscFields['WhisperUserID'].' = \'0\' or t.'.$DiscFields['WhisperUserID'].' = 0 or t.'.$DiscFields['WhisperUserID'].' is null ) order by t.'.$DiscFields['DateLastActive'].' desc limit 0, '.$Limit.';', '', '', '', 0); echo('<ul id="LatestVanillaDiscussions">'); if(!$Data) { echo('<li>[An error occured while retrieving latest discussions]</li></ul>'); return; } while( $Row = $GLOBALS['Context']->Database->GetRow($Data) ) echo('<li><a href="'.VANILLA_DIR.'comments.php?DiscussionID='. $Row['DiscussionID'].'">'.FormatStringForDisplay($Row['Name']).'</a></li> '); echo('</ul>'); } ?>For example, if you put that in a file called 'getdiscussions.php' in your main directory, and your page was in the same dir, then you could use the following snippet to include it:<?php define('VANILLA_DIR', '[your forum subfolder]/'); include('getdiscussions.php'); ?> [your page] <?php GetRecentDiscussions(); ?>Updated the first post, try it now, and make sure it's include()ed before any of the page is outputted.
Open up wp-blog-header.php and find this conditional block:
} else if ( empty($feed) ) { @header('X-Pingback: '. get_bloginfo('pingback_url')); @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); }Then insert somewhere within that conditional the include() code (assuming you've called the file getdiscussions.php):define('VANILLA_DIR', '[vanilla install, relative to wp dir]'); include('getdiscussions.php');Then go into wp-content/themes/[your theme]/sidebar.php and add in the unorded list, wherever you feel the discussion list should go:<li>Lastest Discussions<?php GetRecentDiscussions(); ?></li>But, assuming you just want the list on the front page, add this right after the call to gzip_compression() in wp_blog_header.php:
if(is_home() || is_page()) { define('VANILLA_DIR', '[vanilla_dir]'); include('getdiscussions.php'); }Then you'd want to modify what you put in the theme file, changing it to this:<?php if(function_exists('GetRecentDiscussions')) { echo('<li><h2>Latest Discussions</h2>'); GetRecentDiscussions(); echo('</li>'); } ?>Sorry for all the confusion.getdiscussions.php is in /forum
your include_path is "." which equates to "/" for the wp-blog-header script.
so no, it's not going to find it because it's not looking in /forum for it
either change your include path to have ":/forum" in it, or change the script to include forum/getdiscussions.php.
include('getdiscussions.php');
change that to
include('forum/getdiscussions.php');
and see where that gets you.
when SirNot said
define('VANILLA_DIR', '[vanilla_dir]');he didn't mean it literally. at least i hope not. he meant for you to replace [vanilla_dir] with your actual vanilla dir. like so:
define('VANILLA_DIR', '/forum/');like i said,
define('VANILLA_DIR', '/forum/');not
define('VANILLA_DIR', '[/forum/]');