Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
how do you add a link into Mark's DiscussionFilter?
strawberries
New
I want to delete the regular 'Start a New Discussion' link at the top left; and instead put the link into the Discussion Fiters panel (ie along with Bookmarked Discussions, Your Discussions, etc)
What code do I need to add below? (I do know that the relevant section is lines 32 - 38)
********************
<?php
/*
Extension Name: Discussion Filters
Extension Url: http://lussumo.com/docs/
Description: Adds quick discussion filters to the panel like "my bookmarks" or "my discussions" or "unread discussions"
Version: 1.0
Author: Mark O'Sullivan
Author Url: http://markosullivan.ca/
Copyright 2003 - 2005 Mark O'Sullivan
This file is part of Vanilla.
Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
The latest source code for Vanilla is available at www.lussumo.com
Contact Mark O'Sullivan at mark [at] lussumo [dot] com
You should cut & paste these language definitions into your
conf/your_language.php file (replace "your_language" with your chosen language,
of course):
*/
$Context->Dictionary["DiscussionFilters"] = "Discussion Filters";
$Context->Dictionary["BookmarkedDiscussions"] = "Bookmarked Discussions";
$Context->Dictionary["YourDiscussions"] = "Your Discussions";
$Context->Dictionary["PrivateDiscussions"] = "Whispered Discussions";
$Context->Dictionary["PrivateComments"] = "Whispered Comments";
if (in_array($Context->SelfUrl, array("categories.php", "comments.php", "index.php", "post.php")) && $Context->Session->UserID > 0) {
$DiscussionFilters = $Context->GetDefinition("DiscussionFilters");
$Panel->AddList($DiscussionFilters, 10);
if (!$Context->Session->User->Preference("ShowBookmarks")) $Panel->AddListItem($DiscussionFilters, $Context->GetDefinition("BookmarkedDiscussions"), GetUrl($Configuration, "index.php", "", "", "", "", "View=Bookmarks"), "", "", 10);
if (!$Context->Session->User->Preference("ShowRecentDiscussions")) $Panel->AddListItem($DiscussionFilters, $Context->GetDefinition("YourDiscussions"), GetUrl($Configuration, "index.php", "", "", "", "", "View=YourDiscussions"), "", "", 20);
if ($Configuration["ENABLE_WHISPERS"] && !$Context->Session->User->Preference("ShowPrivateDiscussions")) {
$Panel->AddListItem($DiscussionFilters, $Context->GetDefinition("PrivateDiscussions"), GetUrl($Configuration, "index.php", "", "", "", "", "View=Private"), "", "", 30);
$Panel->AddListItem($DiscussionFilters, $Context->GetDefinition("PrivateComments"), GetUrl($Configuration, "search.php", "", "", "", "", "PostBackAction=Search&Keywords=whisper;&Type=Comments"), "", "", 40);
}
}
// Apply any necessary filters
if ($Context->SelfUrl == "index.php") {
$View = ForceIncomingString("View", "");
switch ($View) {
case "Bookmarks":
$Context->PageTitle = $Context->GetDefinition("BookmarkedDiscussions");
function DiscussionManager_FilterDataToBookmarks(&$DiscussionManager) {
$s = &$DiscussionManager->DelegateParameters['SqlBuilder'];
$s->AddWhere('b', 'DiscussionID', 't', 'DiscussionID', '=', 'and', '', 0, 1);
$s->AddWhere('b', 'UserID', '', $DiscussionManager->Context->Session->UserID, '=');
$s->EndWhereGroup();
}
$Context->AddToDelegate("DiscussionManager",
"PreGetDiscussionList",
"DiscussionManager_FilterDataToBookmarks");
$Context->AddToDelegate("DiscussionManager",
"PreGetDiscussionCount",
"DiscussionManager_FilterDataToBookmarks");
break;
case "YourDiscussions":
$Context->PageTitle = $Context->GetDefinition("YourDiscussions");
function DiscussionManager_FilterDataToOwnDiscussions(&$DiscussionManager) {
$s = &$DiscussionManager->DelegateParameters['SqlBuilder'];
$s->AddWhere('t', 'AuthUserID', '', $DiscussionManager->Context->Session->UserID, '=');
}
$Context->AddToDelegate("DiscussionManager",
"PreGetDiscussionList",
"DiscussionManager_FilterDataToOwnDiscussions");
$Context->AddToDelegate("DiscussionManager",
"PreGetDiscussionCount",
"DiscussionManager_FilterDataToOwnDiscussions");
break;
case "Private":
$Context->PageTitle = $Context->GetDefinition("PrivateDiscussions");
function DiscussionManager_FilterDataToPrivateDiscussions(&$DiscussionManager) {
$s = &$DiscussionManager->DelegateParameters['SqlBuilder'];
$s->AddWhere('t', 'WhisperUserID', '', $DiscussionManager->Context->Session->UserID, '=', 'and', '', 0, 1);
$s->AddWhere('t', 'AuthUserID', '', $DiscussionManager->Context->Session->UserID, '=', 'or', '', 0, 1);
$s->AddWhere('t', 'WhisperUserID', '', 0, '>', 'and');
$s->EndWhereGroup();
$s->EndWhereGroup();
}
$Context->AddToDelegate("DiscussionManager",
"PreGetDiscussionList",
"DiscussionManager_FilterDataToPrivateDiscussions");
$Context->AddToDelegate("DiscussionManager",
"PreGetDiscussionCount",
"DiscussionManager_FilterDataToPrivateDiscussions");
break;
}
}
?>
0
This discussion has been closed.
Comments
<?php
/*
Extension Name: Start New Discussion -> Discussion Filters
Extension Url: http://www.int0rw3b.com
Description: Places a 'Start New Discussion' link in the Discussion Filters
Version: 1.0
Author: Gerrard Cowburn
Author Url: http://www.int0rw3b.com
*/
if (in_array($Context->SelfUrl, array("categories.php", "comments.php", "index.php", "post.php")) && $Context->Session->UserID > 0 && $Context->Session->User->Permission('PERMISSION_START_DISCUSSION') ) {
$DiscussionFilters = $Context->GetDefinition("DiscussionFilters");
$Panel->AddList($DiscussionFilters, 10);
$Panel->AddListItem($DiscussionFilters, $Context->GetDefinition('StartANewDiscussion'), 'post.php');
}
?>
It's not flawless (I cant quite fathom out how to tell it which category to use), but it works fine. And it's always best to use an extension rather than hacking the source.
You'd probably want to cut the existing start new discussion link out (i assume you can use css, otherwise it's in the theme file) too.
<div id="Body"><div id="Panel"><h1><a href="http://lussumo.com/community/post/">Start a new discussion</a></h1>
Adding that to Minisweeper extension should be enought
$Head->AddString("<style>div#Panel h1 {display:none}</style>");
<?php /* Extension Name: Start New Discussion -> Discussion Filters Extension Url: http://www.int0rw3b.com Description: Places a 'Start New Discussion' link in the Discussion Filters Version: 1.0 Author: Gerrard Cowburn Author Url: http://www.int0rw3b.com */ if (in_array($Context->SelfUrl, array("categories.php", "comments.php", "index.php", "post.php")) && $Context->Session->UserID > 0 && $Context->Session->User->Permission('PERMISSION_START_DISCUSSION') ) { $DiscussionFilters = $Context->GetDefinition("DiscussionFilters"); $Panel->AddList($DiscussionFilters, 10); $Panel->AddListItem($DiscussionFilters, $Context->GetDefinition('StartANewDiscussion'), 'post.php'); $Head->AddString("<style>div#Panel h1 {display: none;}</style>"); } ?>
I'm guessing the most 'vanilla' way to do it would be to:
Open your /themes/ directory and locate panel.php
*Copy* that (panel.php) file into the /themes/vanilla/ directory
Open it up (the new copy), and delete this chunk:
// Add the start button to the panel if ($this->Context->Session->UserID > 0 && $this->Context->Session->User->Permission('PERMISSION_START_DISCUSSION')) { $CategoryID = ForceIncomingInt('CategoryID', 0); if ($CategoryID == 0) $CategoryID = ''; echo '<h1><a href="'.GetUrl($this->Context->Configuration, 'post.php', 'category/', 'CategoryID', $CategoryID).'">' .$this->Context->GetDefinition('StartANewDiscussion') .'</a></h1>'; }
Should do the trick i think...
#Panel h1 { margin-top:20px; font-size:14px; visibility: hidden; }