Just display discussions
                    I'm doing a vanilla install (ps love the script :D) for a friend and I need to just display the discussions and not the header or the sidebar etc. Just the comments. Is there anyway to just include it in? Or just access one page through an iframe (ew) ?
Thanks.                
                0          
             
         
            
Comments
We can tell you exactly what the query should be, but you really should know how to display the records yourself.
<?php $VanillaDir = './'; //(relative) path to your vanilla installation include($VanillaDir.'appg/settings.php'); include_once(sgLIBRARY.'Vanilla.Discussion.class.php'); include_once(sgLIBRARY.'Vanilla.Comment.class.php'); include($VanillaDir.'appg/init_ajax.php'); function GetPreview($Text, $Len) { if(strlen($Text) <= $Len) return $Text; //first check to see if we can seperate paragraphs for($i = $Len; $Text[$i] != "\n" && $Text[$i] != "\r" && $i > 0; $i--) ; if($i > 0) return substr($Text, 0, $i) . ' ...'; //now try punctuation for($i = $Len; !ctype_punct($Text[$i]) && $i >= 0; $i--) ; if($i > 0) return substr($Text, 0, $i) . ' ...'; //and lastly, any spaces for($i = $Len; !ctype_space($Text[$i]) && $i >= 0; $i--) ; if($i > 0) return substr($Text, 0, $i) . ' ...'; //if none of the above, just return a substring return substr($Text, 0, $Len) . ' ...'; } function GetRecentDiscussions($Number = 10, $Preview = 50) { global $Context, $VanillaDir; $s = $Context->ObjectFactory->NewContextObject($Context, 'SqlBuilder'); $s->SetMainTable('Discussion', 't'); $s->AddSelect(array('DiscussionID', 'DateCreated', 'Name', 'AuthUserID', 'DateLastActive', 'LastUserID'), 't'); $s->AddJoin('User', 'lu', 'UserID', 't', 'LastUserID', 'left join'); $s->AddSelect('Name', 'lu', 'LastUserName'); $s->AddJoin('User', 'u', 'UserID', 't', 'AuthUserID', 'left join'); $s->AddSelect('Name', 'u', 'AuthUserName'); $s->AddJoin('Comment', 'c', 'CommentID', 't', 'FirstCommentID', 'left join'); $s->AddSelect('Body', 'c'); $s->AddJoin('Category', 'cg', 'CategoryID', 't', 'CategoryID', 'left join'); $s->AddSelect('CategoryID', 'cg'); $s->AddSelect('Name', 'cg', 'Category'); if($Context->Session->UserID > 0) $s->AddJoin('CategoryRoleBlock', 'crb', 'CategoryID and crb.RoleID = '.$Context->Session->User->RoleID, 't', 'CategoryID', 'left join'); else $s->AddJoin('CategoryRoleBlock', 'crb', 'CategoryID and crb.RoleID = 1', 't', 'CategoryID', 'left join'); $s->AddWhere('coalesce(crb.Blocked, 0)', '0', '=', 'and', '', 0, 0); $s->AddWhere('t.WhisperUserID', 0, '=', 'and', '', 1, 1); $s->AddWhere('t.WhisperUserID', 0, '=', 'or', '' , 0); $s->AddWhere('t.WhisperUserID', 'null', 'is', 'or', '' , 0); $s->EndWhereGroup(); $s->AddOrderBy('DateLastActive', 't', 'desc'); $s->AddLimit(0, $Number); $Data = $Context->Database->Select($Context, $s, 'Extension', 'GetRecentDiscussions', 'An error occurred while retrieving discussions.'); while($Row = $Context->Database->GetRow($Data)) { /* available indexes, for modification: CategoryID, Category, DiscussionID, Discussion, AuthUserID, AuthUserName, LastUserID, LastUserName, Body, Name, DateCreated, DateLastActive */ echo(' <dl class="DiscussionPreview"> <dt><a href="'.$VanillaDir.'comments.php?DiscussionID='.$Row['DiscussionID'].'">'.FormatStringForDisplay($Row['Name']).'</a></dt> <dd class="Label">Category</dd> <dd class="Item"><a href="'.$VanillaDir.'?CategoryID='.$Row['CategoryID'].'">'.FormatStringForDisplay($Row['Category']).'</a></dd> <dd class="Label">Author</dd> <dd class="Item"><a href="'.$VanillaDir.'account.php?u='.$Row['AuthUserID'].'">'.FormatStringForDisplay($Row['AuthUserName']).'</a></dd> <dd class="Label">Last Active</dd> <dd class="Item">'.TimeDiff(UnixTimestamp($Row['DateLastActive']), mktime()).'</dd> <dd class="Label">Last Post By</dd> <dd class="Item"><a href="'.$VanillaDir.'account.php?u='.$Row['LastUserID'].'">'.FormatStringForDisplay($Row['LastUserName']).'</a></dd> <dd class="PreviewText">'.FormatStringForDisplay(GetPreview($Row['Body'], $Preview)).'</dd> </dl>'); } return 0; } ?>And I can post the actual query in readible form as well if you want; couldn't include it in this post because of the character limit.