Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to add a massive post at the end of each thread?

candymancandyman ✭✭
edited June 2013 in Vanilla 2.0 - 2.8

I've closed my phpbb forum two years ago and now I'm going to open it again with Vanilla: for this reason I'd like to add at the end of each thread (there are hundreds...) a post explaining that this is the new post after the closing. A sort of boundary line.
How can I obtain this in a simple way without manually writing a post in every thread?
Can I give a command in the terminal/myPhpAdmin?
All these "advise post" are by the admin, obviously. Better if they would have the same date&time.

Thanks in advance.

Comments

  • ShadowdareShadowdare r_j MVP
    edited June 2013

    One way to do this is to make a PHP script that queries the database for all the IDs of the discussions and then uses a loop with an array of those discussion IDs that instantiates CommentModel() from Vanilla to create a comment for each discussion ID along with the data for the comment.

    Add Pages to Vanilla with the Basic Pages app

  • R_JR_J Ex-Fanboy Munich Admin
    edited June 2013

    If you want to do this the SQL way, you could use the script below.

    But beware: /!\
    In nearly every software I know, writing directly to the database has some side effects nobody knows of and you should avoid it. I think there is an API and using this one would be much safer, although it would also take much more time.

    But there might be some Plugins which expect additional info per comment and because this isn't provided with the script, either the script will fail or your forum is unusable.

    Or even core functions might not work as expected after inserting comments by SQL. You should get feedback from some experienced Vanilla users before you start the SQL script below!

    
      INSERT INTO `DatabaseName`.`Prefix_Comment` (  
      `DiscussionID`  
        , `InsertUserID`  
        , `Body`  
        , `Format`  
        , `DateInserted`  
        , `InsertIPAddress`  
        )   
      SELECT  
      `DiscussionID`  
        , '1'  
        , 'Here is where phpBB ends and Vanilla arises!'  
        , 'Html'  
        , '2013-07-01 00:00:00'  
        , '127.0.0.1'  
      FROM `DatabaseName`.`Prefix_Discussion`;
    
    

    The code tag is not working the way it should (I'm new to markdown, it could be my fault): maybe you should better quote my posting and look at what I've written instead of using what is showing...

  • hgtonighthgtonight ∞ · New Moderator

    I would implement a plugin that offers the following features:

    • Pick a date for the change over
    • Hook into the discussion controller before comment display and check the Insert date against the change over date.
    • If the date is before the changeover date, flag that a notice is required.
    • If the date is after the changeover date and a notice is required and hasn't been inserted, insert your changeover notice and flag the notice has been inserted.

    This plugin would have the benefit of not inserting a bunch of duplicate data while still being pretty easy to implement.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • peregrineperegrine MVP
    edited June 2013

    if you replace this function in the comment body insert plugin. It will place a message on all the old messages.

    I would put a message on the old messages of the forum rather than the new ones.

    public function DiscussionController_AfterCommentBody_Handler($Sender) {

            //  set your crossover date here
            $mydate = strtotime("19 June 2013");
    
    
            $commentitem = (C('Plugins.CommentBodyInsert.Name1'));
           $instime = strtotime($Sender->EventArguments['Discussion']->DateInserted); 
           if ($instime == "") {
           $instime = strtotime($Sender->EventArguments['Object']->DateInserted);
           } 
           $checktime = $instime;
    
    
       //   change from greater sign to less than sign if you want to reverse       
          if ( ( (int) $mydate) > ( (int) $checktime) ) {
    
          echo $commentitem;
          }
       }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • candymancandyman ✭✭
    edited June 2013

    I would pay a fee for a working plugin (to be honest I have already contacted Shadowdare for this).
    According to you is it possible to run a script which can automatically add a comment inside the last post of every thread posted before a specific date?
    My original idea was to adding a post (containing an image) after the conclusion of every posts written in the old era.
    A sort of visible border.

    LAST POST

    image

    NEW POST

    Anyway, I would not that a tons of posts with the same date&time could create problems to the search engine.
    I hope that different post IDs could avoid this, aren't they?

    Thanks all for the useful suggestions.

    p.s.: the optimum would be the possibility to use some css tricks to do the job... :|

  • peregrineperegrine MVP
    edited June 2013

    @candyman

    I would pay a fee for a working plugin (to be honest I have already contacted Shadowdare for this).

    If @Shadowdare doesn't have the time or desire, pm with the amount you would pay. But only if @Shadowdare doesn't have the time or desire, i could do it for you.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited June 2013

    As far as my test using peregrine's comment insert plugin , you can add anything to the comments anywhere you want . even after the signatures or anywhere you want.

    I was able to add, flash content, images, text, javascript. And I used css to put it anywhere I wanted.

    public function DiscussionController_BeforeCommentBody_Handler($Sender) {

    puts it in the meta section and you can just use css to make it appear above that

    or

    public function DiscussionController_AfterCommentBody_Handler($Sender) {

    which makes it come out after the comment and use css to make it come out below that.

    It is a great plugin that if you are creative you can do a lot with

  • hgtonighthgtonight ∞ · New Moderator

    @candyman said:
    I would pay a fee for a working plugin (to be honest I have already contacted Shadowdare for this).

    Let me know how this pans out.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • peregrineperegrine MVP
    edited June 2013

    @hgtonight

    Let me know how this pans out.

    "I would pay a fee"

    that wakes us all up :).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.