Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Update for critical security issue in PHPMailer included in release Vanilla 2.3.1
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

Need to sort discussions by Date Created, not Most Recent Comment

DoyceTDoyceT Model Questioner ✭✭
edited September 2014 in Vanilla 2.0 - 2.2

Hi all,

I'm on 2.1.1 stable, running a forum for an online campus.

The faculty/students in particularly active classes are complaining that their classroom areas (read: private Categories) are 'confusing', because "the order in which discussions are listed keeps changing" (obviously, because they're ordered by most-recently-updated)... and apparently they want to be able to memorize the location of each discussion on the screen and click on the G-D thing with their eyes closed, rather than actually reading.

Ahem.

Anyway, I'd "like" to change the display of discussions on the forum - specifically, to order the discussions by the date created.

(Yes, this dumb. Yes, I hate it. Read that as a given.)

I added the following two lines to config...

$Configuration['Vanilla']['Discussions']['SortField'] = 'd.DateInserted';
$Configuration['Vanilla']['Discussions']['SortDirection'] = 'desc';

... as suggested by @hgtonight in this post - http://vanillaforums.org/discussion/comment/180112/ - but it doesn't seem to have any effect. Has the code changed in the last year, to the point where these config settings no longer do anything? Config-defaults.php does not seem to contain any hints on this one.

«1

Comments

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited September 2014

    Look at the class.discussionmodel.php to see where it comes from

        $this->AddArchiveWhere($this->SQL);
    
          if ($Offset !== FALSE && $Limit !== FALSE)
             $this->SQL->Limit($Limit, $Offset);
    
          $this->EventArguments['SortField'] = C('Vanilla.Discussions.SortField', 'd.DateLastComment');
          $this->EventArguments['SortDirection'] = C('Vanilla.Discussions.SortDirection', 'desc');
            $this->EventArguments['Wheres'] = &$Wheres;
            $this->FireEvent('BeforeGet'); // @see 'BeforeGetCount' for consistency in results vs. counts
    
          $IncludeAnnouncements = FALSE;
          if (strtolower(GetValue('Announce', $Wheres)) == 'all') {
             $IncludeAnnouncements = TRUE;
             unset($Wheres['Announce']);
          }
    
          if (is_array($Wheres))
             $this->SQL->Where($Wheres);
    
            // Get sorting options from config
            $SortField = $this->EventArguments['SortField'];
            if (!in_array($SortField, array('d.DiscussionID', 'd.DateLastComment', 'd.DateInserted'))) {
                trigger_error("You are sorting discussions by a possibly sub-optimal column.", E_USER_NOTICE);
          }
    
            $SortDirection = $this->EventArguments['SortDirection'];
            if ($SortDirection != 'asc')
                $SortDirection = 'desc';
    
            $this->SQL->OrderBy($SortField, $SortDirection);
    
          // Set range and fetch
          $Data = $this->SQL->Get();
    

    by the way you should update to 2.1.3 for security and other reasons

  • DoyceTDoyceT Model Questioner ✭✭

    I can't really do a version update until the semester is done.

    (I'm honestly trying not to mess with anything at all while classes are in session, so long as it's working as intended, or enough people complain about something dumb like this.)

  • hgtonighthgtonight ∞ · New Moderator
    1. It should still work in 2.1.1
    2. You should always minor updates rarely break anything and contain security patches. Update.

    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.

  • DoyceTDoyceT Model Questioner ✭✭
    edited September 2014

    @hgtonight said:
    2. You should always minor updates rarely break anything and contain security patches. Update.

    Okay. Updated to 2.1.3. See how I cave under pressure?

    Unfortunately, the fact that those two config lines should work doesn't seem to have any bearing on my forum, which continues to order by most recently updated.

    Update: Annnd it broke file uploading. Awesome.

    Update: And all posting. Double Awesome.

  • peregrineperegrine MVP
    edited September 2014

    you mean the config statements change or the update to 2.1.3....

    if it was the update clear the cache,

    not really needed but ....

    run utility/structure. utility/update.

    reinstall source files if you still have problems. 2.1.3 does work fine,

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

  • hgtonighthgtonight ∞ · New Moderator

    Do you have any plugins that modify the sort field?

    Search for DiscussionModel_BeforeGet_ and report any plugins that use that hook.

    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.

  • DoyceTDoyceT Model Questioner ✭✭

    Updated to 2.1.3.

    Cleared Cache.

    Ran structure and update.

    This is what I get whenever anyone tries to post.

  • peregrineperegrine MVP
    edited September 2014

    check your. .htaccess - did you overwrite it?

    and make sure rewritebase is correct.

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

  • Its still not clear are you just trying to get your forum functional, or are you working on the sorting stuff.

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

  • DoyceTDoyceT Model Questioner ✭✭
    edited September 2014

    I am not trying to reorder the posts anymore. Updating to 2.1.3 has rendered the forum unusable, and I am now trying to address that issue.

  • peregrineperegrine MVP
    edited September 2014

    I would verify .htaccess and fix rewrite base

    check if no go.

    I would re-install source. make sure all files get copied, and then verify .htaccess

    and if you made changes to config-defaults.php which shouldn't be done (since it gets over-written as well)

    where as config.php doesn't get overwritten.

    and remove these lines from config.php

    $Configuration['Vanilla']['Discussions']['SortField'] = 'd.DateInserted';   
    $Configuration['Vanilla']['Discussions']['SortDirection'] = 'desc';   
    

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

  • DoyceTDoyceT Model Questioner ✭✭
    edited September 2014

    .htaccess reads:

    # Original
    # If you modify this file then change the above line to: # Modified
    <IfModule mod_rewrite.c>
       RewriteEngine On
       # Certain hosts may require the following line.
       # If vanilla is in a subfolder then you need to specify it after the /. 
       # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
       # RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
    </IfModule>
    

    Config.php is back to where it was a couple hours before I did anything to it.

    Hitting "post" throws a 404 error for ... something. Can't tell what file it wants that it can't find.

    Hitting post again makes the page go completely blank.

    Also just sitting on the page with the 404 error will make it go blank after about 30 seconds idle.

  • peregrineperegrine MVP
    edited September 2014

    where is your forum folder.
    If vanilla is in a subfolder then you need to specify it after the /.

    uncomment this line and place your forum folder name

    # RewriteBase /

    e.g.

    RewriteBase /forum

    RewriteBase /vanilla

    RewriteBase /whatever

    I would verify .htaccess and fix rewrite base

    check if no go.

    I would re-install source. make sure all files get copied, and then verify .htaccess

    and make sure all folders are readable. and permisions correctly set.

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

    vrijvlinder
  • hgtonighthgtonight ∞ · New Moderator

    What is the URL that is giving you the 404?

    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.

  • LincLinc Vanilla's Bard (and Director of Development) Detroit Vanilla Staff

    It's possible a plugin is overriding your Vanilla.Discussions.SortField.

    Regarding the 2.1.3 broken issue: Are you using a Bluehost 1-click installer, or manually uploading?

    If you are using an installer, verify their version is 2.1.3 and not 2.1.2.

    If you copy the files over yourself, do try copying them all again as peregrine suggested and checking your htaccess is as it should be.

    That 404 error suggests a non-Vanilla problem with your setup - that ain't Vanilla's 404.

  • LincLinc Vanilla's Bard (and Director of Development) Detroit Vanilla Staff

    Would you also humor me and tell me what browser you're using and whether you've tried in any other browsers?

  • DoyceTDoyceT Model Questioner ✭✭

    @peregrine said:
    where is your forum folder.
    If vanilla is in a subfolder then you need to specify it after the /.

    uncomment this line and place your forum folder name

    # RewriteBase /

    .htaccess now reads:

    # Original
    # If you modify this file then change the above line to: # Modified
    <IfModule mod_rewrite.c>
       RewriteEngine On
       # Certain hosts may require the following line.
       # If vanilla is in a subfolder then you need to specify it after the /. 
       # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
       RewriteBase /orca
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
    </IfModule>
    

    Forum is at nila.edu/orca - so that tracks.

    vrijvlinder
  • DoyceTDoyceT Model Questioner ✭✭

    @hgtonight said:
    What is the URL that is giving you the 404?

    I can't exactly tell - it's not actually saying what the 404 file is - just that it can't find a file when I try to post.

  • DoyceTDoyceT Model Questioner ✭✭

    @Linc said:
    Regarding the 2.1.3 broken issue: Are you using a Bluehost 1-click installer, or manually uploading?

    Nah, I uploaded the archive, unarchived, and copied everything over into the directory.

    If you copy the files over yourself, do try copying them all again as peregrine suggested and checking your htaccess is as it should be.

    I'll give it a shot, but I think I'm on about my fourth copy-over.

  • peregrineperegrine MVP
    edited September 2014

    a change in .htaccess isn't always immediate. that could be your issue now that you have changed .htaccess.

    on localhosts ubuntu one has to apache2ctl for immediate change.

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

  • I can't exactly tell - it's not actually saying what the 404 file is - just that it can't find a file when I try to post.

    as an aside....

    you should be able to see this in your apache logs

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

  • DoyceTDoyceT Model Questioner ✭✭

    Sure, but... .htaccess hasn't been "right", basically, ever, and it's been working fine.

  • DoyceTDoyceT Model Questioner ✭✭

    Update:

    New discussions can be posted without error.

    Private messages can be replied to.

    Only comments to existing discussions throw the 404.

  • peregrineperegrine MVP
    edited September 2014

    Only comments to existing discussions throw the 404.

    do you see js errors anywhere.

    and check your apache errorlog.

    you could also try disabling all your plugins and see if you get error.

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

  • peregrineperegrine MVP
    edited September 2014

    .

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

  • DoyceTDoyceT Model Questioner ✭✭
    edited September 2014

    I updated the 404 file to kick out the requested URL.

    Then, tried to post a reply to http://nila.edu/orca/discussion/699/

    And the 404 after hitting post was generated for /orca/vanilla/post/comment/?discussionid=699

    ... and then I looked at that and said "Why the fuck is it trying to go into a Vanilla subdirectory?"

    And sure enough, there's an empty Vanilla directory (from when I expanded the archive of 2.1.3 at some point) with nothing in it but an .htaccess file.

    Son of a...

    Deleted said directory, error goes away.

    R_Jhgtonight
  • peregrineperegrine MVP
    edited September 2014

    :smiley:

    so you solved it! I take.

    so, it was .htaccess after all?

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

    DoyceT
  • peregrineperegrine MVP
    edited September 2014

    sometimes copying doesn't copy hidden files e.g. with the dot. .htaccess

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

    DoyceT
  • DoyceTDoyceT Model Questioner ✭✭

    @peregrine said:
    so, it was .htaccess after all?

    It was .htaccess - in that there was an .htaccess in a subdirectory under the main vanilla folder that was being read instead of the proper one. Yeeesh. Tricky.

    peregrinehgtonight
  • LincLinc Vanilla's Bard (and Director of Development) Detroit Vanilla Staff

    Congrats; tricky bug. Sorry about the panic, that's never fun. Rest assured, the effort was worth it. There were some mean security issues you just patched.

    peregrinehgtonight
«1
Sign In or Register to comment.