20100716 Dynamic Display Block not sorting nicely
Well, I finally got tired of trying to manage the Dynamic Display slider area by re-editing new nodes to get the order right. We tried resetting the posting date, but it had no effect. So, I dug into the ddblock module to find out why. Simply, there was no option to use the news item fetch from the database without RESORTING it somehow, because there were only three options: random, ascending, and descending, and the ordered sorts were tied to Node ID. This can be fixed, to allow the views module item "news item" to do the sorting, and have the ddblock module leave it alone.
This requires an edit of the script "ddblock.module", but it's not complicated.
- Save a copy of the original "ddblock.module" as ... perhaps ... "ddblock.module.original".
- Edit "ddblock.module", and search for occurances of "random". There are three basic places where you will find that word: setting default values, selecting options, and a "case" statement where the sorting is done.
- Ignore the setting of default values. It's "random" now, and that's fine.
- Where you find the lines allowing selection of random, ascending, or descending, add one more item, by typing ", 'none' => t('None')" just before the closing parenthesis on that line. There should be two occurances of option selection in the file.
- Where you find a "case" statement, observe that there are cases for the three original options -- random, ascending, and descending. Add one more case statement: "case 'none': break;". I put it above the case statement for "random", but it does not matter, as long as it's in that block of code with the others. Observe the code format, and just put it in so it does not disrupt the flow of things.
- Save the edited module, and upload it to the site.
- Edit the news item view, and select the sort order you would like to see.
- Navigate -> Administer -> Site Configuration -> Dynamic Display block, and configure the block you are using. Scroll down to the item order option, and select your newly-added "None" option.
- Save, and observe the effect.
For the ORP, we have set the view to sort by posting date, because this is easily modified by editing the news item. Now, in order to "shuffle" the slider display to sort like we want it to, we simply adjust the posting date (the date and time, actually), so that the one we want first has the most recent date. As you might guess, the news item view is configured to sort on Node: Posting date, descending.
I should have done that a long time ago....