13

Is there a way to reorder the content types shown on node/add?

0

2 Answers 2

19

Yup! Simply edit your "Navigation" menu (at /admin/structure/menu/manage/navigation) and reorder the menu entries under "Add content". Now when you go to /node/add they'll appear in whatever order you set them in your "Navigation" menu. Example screenshot below. On /node/add they will appear as Basic Page, then Article.

enter image description here

3
  • oh dear how I could miss that. Feeling stupid... Mar 29, 2012 at 12:14
  • don't, the only reason I realized you could do that was by answering a different question a few days ago... had you asked this last week I'd have had no idea :)
    – Chaulky
    Mar 29, 2012 at 16:57
  • Just a complementary question here : the Add content menu is well reordered in the Nav menu but in the top Admin menu, the order is still alphabetical. Any tip to reorder the Add content entries in the admin menu? Thank you.
    – Toki
    Apr 19, 2016 at 7:02
2

You'd have to resort to a custom module for this as the alphabetical ordering is hard coded into the page callback function node_overview_types() (it's actually built up in _node_types_build() which is called from that function).

Without knowing what you want to sort on it's quite difficult to give a full answer but I'll put the skeleton code in:

function MYMODULE_menu_alter(&$items) {
  // Override the default page callback for the content types page
  $items['admin/structure/types']['page callback'] = 'MYMODULE_node_admin_overview';
}

function MYMODULE_node_admin_overview() {
  // Get the normal page build
  $default_build = node_overview_types();

  // Extract the table rows from the build
  $table_rows = $default_build['#rows'];

  // Perform an operation on these rows to re-order them for your needs
  _some_call_by_reference_sort_function($table_rows);

  // Assign the newly ordered rows back to the page build
  $default_build['#rows'] = $table_rows;

  return $default_build;
}

Make sure you keep your callback function in the main module file otherwise you'll have to mess about with overriding the file key for the original menu item which is never fun.

You'd have to implement your own administration page if you want to be able to change the ordering through the UI.

1
  • Thanks Clive. I just thought there might be a different way.
    – fndtn357
    Feb 5, 2012 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.