Re-add Create content

portulaca - June 25, 2009 - 22:48
Project:Administration menu
Version:6.x-3.x-dev
Component:Code
Category:task
Priority:critical
Assigned:Unassigned
Status:active
Description

I upgraded to 6.x-3.x-dev and everything seems to work fine except there is no Create content link under Content management. Am I missing something?

I'm on Firefox 3, ubuntu jaunty, tested on Garland and one custom theme.

#1

VM - June 25, 2009 - 22:49

doesn't seem to work that way any more you use the create content link in the navigation menu. I've rolled back from 3.x-dev as there are some bugs being worked on that were affecting other things.

#2

muhleder - June 26, 2009 - 17:53

You can move the Create Content tree from the Navigation menu into the Administration Menu though. Need to flush the menu cache to get it to appear though.

Items in the Administration Menu seem to have a path dependency, eg. I couldn't get custom help items to show up until I set a custom path for them under 'admin/instructions'. I'd guess this is why the Create Content tree went awol, the path is 'node/add%' so didn't come under the 'admin/content/%path'

#3

sun - June 27, 2009 - 04:24

FYI: No, the "Create content" sub-menu tree was left out in the rewrite to focus on the main administration menu first. You should be able to simply move the existing items from the Navigation menu into the Administration menu, just like you can move any other items around now. However, I'm not yet sure how to - properly - deal with such customizations in 3.x-dev.

#4

sun - July 23, 2009 - 10:21
Title:Create content missing» Re-add Create content
Category:support request» task
Priority:normal» critical

Applies to 6.x-3.x only.

#5

portulaca - July 23, 2009 - 13:39

yay!

#6

hanoii - August 4, 2009 - 14:14

Interested in this issue

#7

seanr - August 12, 2009 - 20:41

I do think this belongs in the admin menu. One of the usability studies they did for Drupal 7 shows that people intuitively expect to find it in the admin area anyway. Also, on our sites, we completely hide the navigation menu, relying exclusively on admin_menu for all the site administration stuff including posting content.

#8

milkmiruku - August 15, 2009 - 02:46

i'd welcome the return of this also, thanks.

#9

mdgnavyf - August 15, 2009 - 10:39
Assigned to:Anonymous» mdgnavyf

#10

mdgnavyf - August 15, 2009 - 10:40
Assigned to:mdgnavyf» Anonymous

#11

mdgnavyf - August 15, 2009 - 10:45

I'm just jumping in Drupal, and have installed 6.13. When you say I can copy or pull the Create Content function to the Admin's menu, where do I find the Navigation Menu? I'm a newbie and hope you guys can help. Thanks.

#12

VM - August 15, 2009 - 17:51

administe -> menus

#13

markus_petrux - August 16, 2009 - 16:35

You can actually add this submenu using hook_admin_menu_output_alter().

<?php
/**
* Implementation of hook_admin_menu_output_alter().
*
* Add "Create content" as a top level submenu in the admin menu.
*/
function mymodule_admin_menu_output_alter(&$content) {
 
// Add a top level item for the Create content menu itself.
 
$content['mymodule'] = array(
   
'#theme' => 'admin_menu_links',
   
'#weight' => -99,
   
'#sorted' => TRUE,
  );

 
// Copy the create content submenu to our backend menu.
 
$content['mymodule']['create-content'] = array(
   
'#title' => t('Create content'),
   
'#href' => 'node/add',
   
'#weight' => -10,
  );
 
$i18nstrings_exists = module_exists('i18nstrings');
  foreach (
node_get_types() as $type) {
    if (
node_access('create', $type->type)) {
     
$type_url_str = str_replace('_', '-', $type->type);
     
$content['mymodule']['create-content'][$type_url_str] = array(
       
'#title' => drupal_ucfirst(!$i18nstrings_exists ? $type->name : tt("nodetype:type:$type->type:name", $type->name)),
       
'#href' => 'node/add/'. $type_url_str,
      );
      if (!empty(
$type->description)) {
       
$description = (!$i18nstrings_exists ? $type->description : tt("nodetype:type:$type->type:description", $type->description));
       
$content['mymodule']['create-content'][$type_url_str]['#options'] = array('attributes' => array('title' => $description));
      }
    }
  }
  if (!empty(
$content['mymodule']['create-content'])) {
   
uasort($content['mymodule']['create-content'], '_mymodule_element_sort');
  }
}
function
_mymodule_element_sort($a, $b) {
 
$a_title = (is_array($a) && isset($a['#title'])) ? $a['#title'] : '';
 
$b_title = (is_array($b) && isset($b['#title'])) ? $b['#title'] : '';
  return
strcasecmp($a_title, $b_title);
}
?>

#14

sun - August 16, 2009 - 21:51
Status:active» fixed

Thanks for reporting, reviewing, and testing! Committed attached patch to 3.x.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

AttachmentSize
admin_menu-DRUPAL-6--3.create-content.patch 2.03 KB

#15

Bartezz - August 18, 2009 - 08:52

Just downloaded the 6.x-3.x-dev 2009-Aug-17, it's working great, no bugs so far... Loving it!
Thanx for bringing it back!

#16

eMPee584 - August 18, 2009 - 19:17
Status:fixed» active

Sorry to spoil the cake... there are several modules who check arg(0) to see if they are on the node add form, the most prominent one being

<?php
pathauto_form_alter
(&$form, $form_state, $form_id) {
 
// Only do this for node forms
 
if (isset($form['#id']) && ($form['#id'] == 'node-form') && arg(0) == 'node') {
  ...
?>

It's surely not a grave issue - but it is a problem.

#17

rokr - August 20, 2009 - 20:02

The actual path for adding new content is /admin/node/add/contenttype instead of /node/add/contenttype. A bug or did i miss something? Using 3.0-alpha3.

cheers, Ronald

#18

seanr - August 26, 2009 - 18:44

Why should pathauto need to use arg(0)? Shouldn't the form_id be sufficient?

#19

Dave Reid - August 26, 2009 - 18:48

@rkr: The actual normal drupal path for adding a node is node/add/x. See http://api.drupal.org/api/function/node_menu/6
@seanr: Patch for pathauto in #369840-54: If a user changes the automatic path, try to remember that in the future removes the need for arg and uses $form_id comparison.

#20

rokr - August 26, 2009 - 20:23

What i wanted to say: the actual path admin menu provides for adding new content: /admin/node/add/content-type which *should* be without the leading "admin" path.

cheers, Ronald

#21

eMPee584 - August 27, 2009 - 13:03

@19: well unfortunately, pathauto isn't the only module doing that kinda stuff... i found others but no time regexping them right now..

#22

markus_petrux - August 27, 2009 - 13:29

OG also depens on 'node/add/*' and not 'admin/node/add/*'. See og_determine_context().

I think admin_menu would have to create additional menu links rather than changing existing menu paths.

#23

markus_petrux - September 1, 2009 - 17:44

In the meantime, we're using a variation of the code I posted in #13 to append the "Create content" submenu using 'node/add' instead of 'admin/node/add', and because we need this rendered on a different location of the admin_menu.

And here's how we can get rid of the 'admin/node/add' entries:

<?php
/**
* Implementation of hook_menu_alter().
*
* Needs to be executed after admin_menu, so mymodule weight
* needs to be adjusted accordingly at hook_enable() time. :P
* Note that admin_menu's weight is 100.
*/
function mymodule_menu_alter(&$items) {
  foreach (
$items as $path => $item) {
   
// See http ://drupal.org/node/502500 Re-add Create content.
   
if (strpos($path, 'admin/node/add') === 0) {
      unset(
$items[$path]);
    }
  }
}
?>

Hope that helps someone. :P

#24

brisath - October 18, 2009 - 09:51

Subscribing

#25

jwuk - October 20, 2009 - 22:21

Subscribing

#26

milkmiruku - October 20, 2009 - 23:25

this issue is resolved in the latest 6.x-3.x-dev, no?

(well, it's back for me anyway :)

#27

jsm174 - November 5, 2009 - 02:46

Same thing here. Create Content is gone for me in 6.x-3.x-dev. Just reinstalled alpha 3 and it's back.

 
 

Drupal is a registered trademark of Dries Buytaert.