Created by: John D Wells ([email protected]) on 2015/03/13 14:23:28 +0000
Votes at time of UserVoice import: 24
Right now by default, adding a new entry to a Structure section places the entry at the end/bottom of the tree level. It might be useful if we could configure entries to placed at the top of the tree level instead.
Here's the use case: We are using a flat (e.g. 1 level) Structure section to manage products in a shop. This allows the client to specify the exact ordering of their shop products on the main "shop" page. However every time a new product is added, it is added to the bottom, and they have to drag it back up to the top.
craft/app/services/EntriesService.php
on line: 222
Change appendToRoot
and append
to prependToRoot
and prepend
if (!$entry->parentId)
{
craft()->structures->prependToRoot($section->structureId, $entry);
}
else
{
craft()->structures->prepend($section->structureId, $entry, $parentEntry);
}
+1 for this.. I think 90% of the time people would like the new entry to be on top.. Why add something new to your site and then have visitors scroll all the way down in order to see it?
Seems like the best way would just to allow the Ascending or Descending options to the control panel and then also allow the drag/drop function. At the moment it is grayed out.
+1. Or being able to specify for each structure whether new entries go to the top or bottom could be a good solution.
It would need to manifest itself as a setting on the Edit Entry page. The index page has nothing to do with it.
A setting on the Edit Entry page would be great. Ideally it would persist for all users, so you wouldn't need to keep guiding new users on how to stop their entries going to the bottom.
+1 for this — It has come up a few times as a client request on sites we've built
Any chance this will show up in Craft 3.x? :)
I'm going to chip in we also have this use case where we imported a lot of projects and now every-time they add a new project it goes to the bottom of the long list.
For the time being would it be possible to write a small module that hooks on the save event of a project in our case and updates the order ? (I'm quite new with CraftCMS so I'm not sure if my idea would be possible)
If anyone else search for a temporary solution for this; the line needed to be changed is different now than angrybrads comment from 2017.
The change needed is in src/services/Structures.php line 281
appendTo needs to be changed to prependTo.
return $this->_doIt($structureId, $element, $parentElementRecord, 'appendTo', $mode);
Wouldn't that be a perfect feature for the upcoming 3.2 release! :wink:
Is this likely to be added in 3.5?
is there a drop in module we can use to fix this for now? Without editing the core files, as per the thread suggestions.
I’ll add it to the 3.5 milestone and see if I get some time to look into this. Think ideally each structure section entry would just have “Add entry above” / “Add entry below” actions you could select on the Entries index.
Hi, my customer has over 1250 entries...
Dragging the entry from the bottom to the top is not really an option :)
The fix posted by eddiedale on 29 May 2019 is working, although it is on line 285.
Can't actually believe this issue hasn't been addressed since 2017?!
Think ideally each structure section entry would just have “Add entry above” / “Add entry below” actions you could select on the Entries index.
+100 – when an author wants to create a new structure entry, typically the author wants that entry to sit at a particular position (i.e. not the bottom _or_ the top). A feature similar to how Matrix solves this (including the option to create a specific _entry type_ at a specific position in the structure) would be awesome, and would improve the AX in working with larger structures _a lot_.
It'd also be great if it was possible to create child elements directly from the element index (similarly to the Child Me! plugin). Perhaps that should be its own FR, but it feels very related to this ☝️
Just got around to this for Craft 3.7:
Most helpful comment
Just got around to this for Craft 3.7: