Jump to content

Template-specific default sort settings


teppo
 Share

Recommended Posts

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!)

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).

  • Like 2
Link to comment
Share on other sites

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.. :)

Link to comment
Share on other sites

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.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...