Jump to content


Photo

Template-specific default sort settings

sort

  • Please log in to reply
6 replies to this topic

#1 teppo

teppo

    Sr. Member

  • Members
  • PipPipPipPip
  • 388 posts
  • 385

  • LocationFinland

Posted 08 May 2012 - 06:25 AM

Couldn't find another topic on this, so I'm creating a new one.

My idea (wish, if you wish.. no pun intended) is actually quite simple: wouldn't it make sense to enable sort order setting for templates in addition to individual pages? That way I wouldn't have to re-set sort order every time I create, for an example, a news page (which can only contain news items and thus has pretty much only one usable sort order throughout the site.)

Also: current default sort value for new pages is "none", which can produce quite peculiar effects - apparently because DB itself uses some very obscure magic for deciding sort order - and I'm having hard time figuring out why anyone would wish it to act like this. As a second idea, wouldn't it be nice if default sort order was "created" instead of "none"?

So - what do other folks think about these? :)

Oh, and by the way, if there already IS a way to achieve one (or both) or ideas above, that'd be great (and in that case, sorry for the confusion!)

#2 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,521 posts
  • 845

  • LocationVihti, Finland

Posted 08 May 2012 - 07:36 AM

Template based default sort order is definitely nice idea.

Also: current default sort value for new pages is "none", which can produce quite peculiar effects - apparently because DB itself uses some very obscure magic for deciding sort order - and I'm having hard time figuring out why anyone would wish it to act like this. As a second idea, wouldn't it be nice if default sort order was "created" instead of "none"?


Are you referring to admin sorting? If you have there "created" set, then you cannot resort them manually, since created is forced. I haven't noticed any strange behavior when adding new pages... always assumed they are created as last ones, if there isn't any sorting set. But after quick testing there actually was different behavior: usually new page went as last one, but sometimes as second last or third last. So it would definitely be better to have new pages as first or as last pages when using custom sorting.

#3 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3109

  • LocationAtlanta, GA

Posted 08 May 2012 - 12:06 PM

My idea (wish, if you wish.. no pun intended) is actually quite simple: wouldn't it make sense to enable sort order setting for templates in addition to individual pages?


I think it makes sense, and have recently had the same wish. Adam brought this up a long time ago, and I've been meaning to add it, but just haven't gotten around to it yet. Now that there's been another request for it, I'll push this forward sooner rather than later. Actually now that my mind is on it, I think I'm going to work on it over lunch break. :)

The plan is that when you select a default sort at the template level, the option no longer appears with the page (i.e. template setting, if used, overrides page). If you select 'none' (the default), then it can still be set at the page level.

Also: current default sort value for new pages is "none", which can produce quite peculiar effects - apparently because DB itself uses some very obscure magic for deciding sort order - and I'm having hard time figuring out why anyone would wish it to act like this. As a second idea, wouldn't it be nice if default sort order was "created" instead of "none"?


When no sortfield is set, pages sort ascending by the database field 'pages.sort'. When you create pages in the admin, they should get added in the order you create them, as ProcessPageAdd manually sets this. That would look like 'created' order. But when you create pages in the API (or any kind of import process), and don't set the 'sort' field of a page, then they are all going to have the same sort value (0), which makes order unpredictable. I actually modified that yesterday when I was fixing the drag-sort issue that smd found, and committed it this morning. Now $pages->save() takes care of setting a $page->sort value if you don't, so it should be more API friendly. The reason we don't want to default sort by something like 'created' is for the reason Antti mentioned (no ability to manually sort).

#4 teppo

teppo

    Sr. Member

  • Members
  • PipPipPipPip
  • 388 posts
  • 385

  • LocationFinland

Posted 09 May 2012 - 12:26 AM

The plan is that when you select a default sort at the template level, the option no longer appears with the page (i.e. template setting, if used, overrides page). If you select 'none' (the default), then it can still be set at the page level.


Sounds great!

But when you create pages in the API (or any kind of import process), and don't set the 'sort' field of a page, then they are all going to have the same sort value (0), which makes order unpredictable.


Makes sense. In my case this problem appeared after importing pages with ImportPagesCSV module.. :)

#5 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3109

  • LocationAtlanta, GA

Posted 09 May 2012 - 12:01 PM

I've got this all working now. It took a little more work than I initially thought, so just need to test for a couple days on this end to make sure I haven't introduced any new bugs.

#6 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,521 posts
  • 845

  • LocationVihti, Finland

Posted 13 May 2012 - 02:12 PM

And Ryan also committed this now: https://github.com/r...c959feb293347b2

#7 teppo

teppo

    Sr. Member

  • Members
  • PipPipPipPip
  • 388 posts
  • 385

  • LocationFinland

Posted 16 May 2012 - 12:56 AM

Testing it right now and seems solid. Many thanks to Ryan, this'll come in handy :)





Also tagged with one or more of these keywords: sort

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users