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.

Set Categories as Homepage / Starting Point / Frontpage :-)

edited August 2006 in Vanilla 1.0 Help
I read a lot on the forum but couldn't find an answer, so here's a quick'n dirty but perfectly working solution: What we're gonna do is find out from which page we have come to the forum. If you were already on vanilla forum, then just go to index.php If you were on another page or just openened a new browser window, goto categories.php should you have any questions, feel free to comment the post and I'll answer ;) here's the full code of index.php. Exchange MYURL with your url: $referer = $HTTP_REFERER; if (! strpos($referer, "MYURL")) { echo "<meta http-equiv=\"refresh\" content=\"0;url=http://MYURL/categories.php\">"; } else { 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(); }


  • Options
    This is why God invented <code>
  • Options
    god didn't invent code and code in the vanilla forum didn't work. any valuable comments?
  • Options
    Yeah. Firstly isn't !strpos(string) meant to be a bad way of checking if a string contains another (because strpos returns the index, which can be 0)? Secondly, wouldn't an HTTP redirect be cleaner and standards-compliant (rather than putting a <meta> tag before anything else in the output), and negate the need to bracket the whole of the rest of the file in an "else" statement (since you can just redirect and exit)? Thirdly, Markdown has code-listing syntax.
  • Options
    Oh, and MYURL can easily be determined by the script rather than hard-coded.
  • Options
    Didn't mark implement an option within the settings file to define what the first base URL is?
  • Options
    KrakKrak New
    edited December 2005

    Is a http redirect/meta better than doing it like header('location: MYURL') ?

    Other than that, not bad, interesting concept.

  • Options
    thanks for your comments! yes, there would be some not so quick'n-dirty solutions but as there have been no specific answers and my PHP is not excellent it turned out like this :-) redirecting with location: didn't work as the headers were already sent. when I tried code in markdown the whole page was too wide, meaning the code ran too far to the right and scrollbars apppeared. best regards, nader
  • Options
    I have actually wondered about how to do this, thank you a lot!
  • Options
    edited January 2006
    $referer = $HTTP_REFERER;

    You should be using the "medium" form.

    $referer = $_SERVER[’HTTP_REFERRER’];

    Incase register_globals is off...

    Also, you should be using header() redirects.

    header("Location: path/to/file");
  • Options
    i tried this one, it doesnt work for me.. I am using Vanilla as a forum between me and my customers so that they can send me their inquiries to the forum and i reply them in the forum , too. doing this I can reach all my offers whereever I go (and I travel a lot). So it would really be a very good idea to have the categories on start page for me... any new ideas ?
  • Options
    the code above didn't do anything, only see a page of code
This discussion has been closed.