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.
Options

how do you add a link into Mark's DiscussionFilter?

edited August 2006 in Vanilla 1.0 Help
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; } } ?>

Comments

  • Options
    I'm pretty sure you dont have to touch any of that. If you just use
    <?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.
  • Options
    Many thanks, mini! Works like a dream. Now to go and delete the existing link to Start a New Discussion.
  • Options
    hmmmm, I have had no luck in deleting the regular 'Start A New Discussion' text/link. Looking here in the vanilla.css file, not able to find the text. :(
  • Options
    edited August 2006
    Here <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>");
  • Options
    edited August 2006
    thanks for the post, dinaboff a little confused tho...unsure of what files to add which code to I added that second bit of code (above) to minisweeper's extension.....nothing happeened tho. Do I have to add the first bit of code somewhere? Thanks for your patience.
  • Options
    edited August 2006
    Havn't try it, But i think it should work:
    <?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>"); } ?>
  • Options
    thanks for trying. But no, no joy...didn't work....'Start a New Discussion' is still up there :(
  • Options
    edited August 2006
    sorry. it's #Panel h1 (just edited the other posts with a capital P).
  • Options
    edited August 2006
    I'm not sure blanking any h1's in the panel is such a great idea? Though it should work...
    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...
  • Options
    a_ja_j
    edited August 2006
    can't you just do it under /* Panel.. */ in vanilla.css?

    #Panel h1 { margin-top:20px; font-size:14px; visibility: hidden; }
  • Options
    Dinoboff, thanks, that capital P now works a treat! Looks swell. Thanks Mini and a_j.......gonna look at your ideas in the morning. Mini, is a really bad idea to blank h1's in the panel? It seems to work so well...and is nice and clean i.e. everything is contained within the extension.
  • Options
    Well in theory it's fine, i just figured if something else added something to the panel in h1 tags you wouldnt see it either.
  • Options
    good point, mini. I must tweak around in the code a bit more. Thanks for all the help.
  • Options
    Well the thing i suggested up there will work fine. And be alright with upgrades and things.
This discussion has been closed.