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.
Setting Categories as Frontpage
Hello, I've been trying to do alot of tweeking to Vanilla recently, and one of the things I've been stuck on for awhile is making the "Categories" tab the default, since my forum has many different things all going on at once and it makes it look a bit like someone barfed something up when you look at the frontpage (it goes from stupidity like "count to infinity", to totally different things, like coding and such), so I recently read this discussion on setting the categories, but I've kind of attacked the original script there, so I was hoping maybe someone would be able to help me out with what I've done wrong..
The editted index.php looks like this:
I'm very new to PHP (I'm only 15 and I've been learning since maybe December, but for a long time in between I'd lost my computer to a virus =(...) But I can't see anything wrong. As far as I interprete the code IF the page before was the index.php then it will redirect to the categories.php page. If not, then it will continue to load the recent discussions list. But instead, no matter what the last page the user loaded, it brings you back to categories.php
Any ideas on fixing this? Did I leave out anything that you might need to know? ^^;;
The editted index.php looks like this:
<?php
/*
* 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
* Description: Display and manipulate discussions
*/
// 1. DEFINE VARIABLES AND PROPERTIES SPECIFIC TO THIS PAGE
$referer = $_SERVER['HTTP_REFERRER'];
if (! strpos($referer, "http://www.infinite9.net\vitae\index.php")) {
header("Location: categories.php");
} else {
include("appg/settings.php");
$Configuration['SELF_URL'] = 'index.php';
include("appg/init_vanilla.php");
include("appg/settings.php");
include_once(sgLIBRARY."Vanilla.Discussion.class.php");
include_once(sgLIBRARY."Vanilla.Comment.class.php");
include_once(sgLIBRARY."Vanilla.Search.class.php");
include_once(sgLIBRARY."Utility.Pagelist.class.php");
include("appg/init_internal.php");
// 1. DEFINE VARIABLES AND PROPERTIES SPECIFIC TO THIS PAGE
// Ensure the user is allowed to view this page
$Context->Session->Check(agSAFE_REDIRECT);
// Instantiate data managers to be used in this page
$DiscussionManager = $Context->ObjectFactory->NewContextObject($Context, "DiscussionManager");
$SearchManager = $Context->ObjectFactory->NewContextObject($Context, "SearchManager");
// Define properties of the page controls that are specific to this page
$Menu->CurrentTab = "discussions";
$Panel->CssClass = "DiscussionPanel";
$Body->CssClass = "Discussions";
// 2. BUILD PAGE CONTROLS
// Panel
AddDiscussionOptionsToPanel($Context, $Panel);
AddBookmarksToPanel($Context, $Panel, $DiscussionManager);
AddDiscussionsToPanel($Context, $Panel, $DiscussionManager, "GetDiscussionsByUserID", agPANEL_USERDISCUSSIONS_COUNT, $Context->GetDefinition("YourDiscussions"), "Recent", $Context->Session->User->Setting("ShowRecentDiscussions"));
AddDiscussionsToPanel($Context, $Panel, $DiscussionManager, "GetViewedDiscussionsByUserID", agPANEL_HISTORY_COUNT, $Context->GetDefinition("History"), "History", $Context->Session->User->Setting("ShowBrowsingHistory"));
AddSearchesToPanel($Context, $Panel, $SearchManager, agPANEL_SEARCH_COUNT);
AddAppendixToPanel($Context, $Panel, "Discussion");
AddTextModeToPanel($Context, $Panel);
AddGuestInfoToPanel($Context, $Panel);
// Add the discussion grid to the body
$CategoryID = ForceIncomingInt("CategoryID", 0);
$View = ForceIncomingString("View", "");
$DiscussionGrid = $Context->ObjectFactory->NewContextObject($Context, "DiscussionGrid", $DiscussionManager, $CategoryID, $View);
$Body->AddControl($DiscussionGrid);
// 3. ADD CONTROLS TO THE PAGE
$Page->AddControl("Head_Render", $Head);
$Page->AddControl("Menu_Render", $Menu);
$Page->AddControl("Panel_Render", $Panel);
$Page->AddControl("Body_Render", $Body);
// 4. FIRE PAGE EVENTS
$Page->FireEvents();
}
?>
I'm very new to PHP (I'm only 15 and I've been learning since maybe December, but for a long time in between I'd lost my computer to a virus =(...) But I can't see anything wrong. As far as I interprete the code IF the page before was the index.php then it will redirect to the categories.php page. If not, then it will continue to load the recent discussions list. But instead, no matter what the last page the user loaded, it brings you back to categories.php
Any ideas on fixing this? Did I leave out anything that you might need to know? ^^;;
0
This discussion has been closed.
Comments
go into conf/settings.php
change this:
$Configuration['FORWARD_VALIDATED_USER_URL'] = 'http://your.site/forum/';
to this:
$Configuration['FORWARD_VALIDATED_USER_URL'] = 'http://your.site/forum/categories.php';
and add these two lines:
$Configuration['TAB_POSITION_DISCUSSIONS'] = '20';
$Configuration['TAB_POSITION_CATEGORIES'] = '10';
then go into your .htaccess file in your forum root and add:
DirectoryIndex categories.php
//actually that won't quite work... "discussions" tab link would take you to categories. let me see
if (! strpos($referer, "http://www.infinite9.net\vitae\index.php")) {
if ($Context->SelfUrl == 'index.php' && ForceIncomingInt('CategoryID', 0) == 0) { header('location:categories.php'); }
I don't see how you could do that in an addons.
The theory behind my code up there is that if they don't click on a category name to get to the discussions in that category, they will be sent to the category page. In other words, you can't ever see all of the discussions at once.
Yes, this can be done as an extension, like this:
<?php /* Extension Name: Category Page First Extension Url: http://lussumo.com/docs/ Description: Makes the category page the default page. Version: 1.0 Author: Mark O'Sullivan Author Url: http://www.markosullivan.ca/ */ // Make the category tab come first. $Configuration['TAB_POSITION_CATEGORIES'] = '10'; $Configuration['TAB_POSITION_DISCUSSIONS'] = '20'; // If looking at the discussions without a category specified, send them to the category page. if ($Context->SelfUrl == 'index.php' && ForceIncomingInt('CategoryID', 0) == 0) { header('location:categories.php'); } ?>