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.

Disable posting to a discussion

edited September 2008 in Vanilla 1.0 Help
I have several Categories, but in the "General" category my first message is a welcome to new members and visitors. I want it to always stay at the top and not allow anyone to post more messages to it. I would also like to not have it say, "[Sticky, Closed]" if possible. Any ideas are appreciated!! www.cfcare.org/forum

Comments

  • SubJunkSubJunk ✭✭
    edited September 2008
    Well you could make your Welcome topic and close it, then add the following to line 16 of themes/discussions.php:

    $catID = $_GET['CategoryID']; if ($catID == "1" || empty($catID)) { echo ' <li id="Discussion_0" class="Discussion Read NoNewComments NoReplies Category_1"> <ul> <li class="DiscussionTopic"> <span>discussion topic</span><a href="linkToWelcomeDiscussion">Welcome</a> </li> <li class="DiscussionCategory"> <span>Category </span><a href="linkToGeneralCategory">General</a> </li> <li class="DiscussionStarted"> <span><a href="linkToWelcomeDiscussion">Started by</a> </span><a href="linkToAdminAccount">Admin</a> </li> </ul> </li> '; }

    Replacing the links where appropriate
  • Per your suggestion I added the above code to line 16, which fell between <li class="DiscussionType">... AND <li class="DiscussionTopic">..., and I now receive the following error message: "Parse error: parse error, unexpected T_STRING in /home/content/f/a/m/family1care/html/forum/themes/discussion.php on line 16" What I would really like is something like what is on the Lussumo Community page, below the tabs and above the discussions. There's says, "Welcome Guests" and is visible just to guests. Mine would just say, "Welcome" and would be available to all. However, I would want it to open up the message much like a discussion does, but without reply capability.
  • then it's just a link to a discussion where nobody can post (just the user/admin who created that discussion/message) ?
  • :-) Not quite sure what you just said, but it sounds right. If you look at my "Welcome" message in the General Discussion category [ www.cfcare.org/forum ] that is the message I want. It can stay right there, but I want it to always be on top and not allow anyone to post to it. I would also like it to not have to say, "[Sticky, Closed]". A link from the main Categories page would be nice, but not necessary. I hope that is clear... Thanks!
  • why dont you just use this http://lussumo.com/addons/index.php?PostBackAction=AddOn&AddOnID=96
  • SubJunkSubJunk ✭✭
    edited September 2008
    mike, I said discussions.php not discussion.php :) Line 16 should be a blank line
  • Wow, that is great! Now is there a way to have it on the categories page (since that is my default page) or at the top of my General Discussions page?
  • edited September 2008
    Thank you Sub Junk. I missed that "s". So, that is getting closer, however I am now seeing both the link "Welcome" and the actual discussion "Welcome". And both still allows posting even though it is closed. How do I make the actual discussion not visible and so that the post screen is gone? Also, I am now getting this error message: "Notice: Undefined index: CategoryID in /home/content/f/a/m/family1care/html/forum/themes/discussions.php on line 16"
  • SubJunkSubJunk ✭✭
    edited September 2008
    Oh yeah that damn undefined index thing is so weird, PHP just gets more like C every day :p
    $catID; if (!empty($_GET['CategoryID'])) { $catID = $_GET['CategoryID']; } if ($catID == "1" || empty($catID)) { echo ' <li id="Discussion_0" class="Discussion Read NoNewComments NoReplies Category_1"> <ul> <li class="DiscussionTopic"> <span>discussion topic</span><a href="linkToWelcomeDiscussion">Welcome</a> </li> <li class="DiscussionCategory"> <span>Category </span><a href="linkToGeneralCategory">General</a> </li> <li class="DiscussionStarted"> <span><a href="linkToWelcomeDiscussion">Started by</a> </span><a href="linkToAdminAccount">Admin</a> </li> </ul> </li> '; }
    That should fix that undefined index error.

    It probably still allows posting in closed discussions because you are the admin account, try making a normal user account and try to post in there.

    To make the discussion not show up twice just add this to line 12 of discussion.php (no "s" this time):
    $discussionID = $Discussion->DiscussionID; if($discussionID != "3") {
    and this to what will now be line 51 (the blank line before $this->CallDelegate('PostDiscussionOptionsRender');):
    }
    Sorry Vanilla guys for ruining your lovely code :p
    I don't recommend this code I'm writing for everyone, I mean if I were to write an extension for it I would do it better, but as it is this messy workaround should work no problem. Make sure you keep a record of these changes you make though (just make a text file and save my posts in it if you want) so that when a new version of Vanilla comes out you can re-apply them when you upgrade.
  • Thanks Sub Junk. Well I think we might be getting closer, however, after changing to the above code I now get error message: "Notice: Undefined variable: catID in /home/content/f/a/m/family1care/html/forum/themes/discussions.php on line 18" And when I added the above code to eliminate the duplicate 'Welcomes' I now get erro message: "Parse error: parse error, unexpected '}' in /home/content/f/a/m/family1care/html/forum/themes/discussion.php on line 50" and none of my discussions are showing now.
  • SubJunkSubJunk ✭✭
    edited September 2008
    Oh I see you are using an old version of Vanilla so our files will be different, perhaps that is the cause. First, update to Vanilla 1.1.5a, it fixes security bugs and adds cool new behind the scenes stuff for extensions to use. I have tested the code I've been giving you on 1.1.5a so it should work.
    Alternatively maybe I have just been unclear in my instructions, so just to be safe here are the changed files for you, just unzip and replace.
  • That's it!! Thank you! Since I just downloaded and installed Vanilla less than a month ago, I would never have guessed that I had an old version. But I see now that the new one just hit less than a week ago. I now have it, have reapplied your recommended changes, and it is working as expected. I appreciate all your help.
  • That's great news, glad to help mate :)
This discussion has been closed.