When you want a menu item with the same title as the node you're creating, you should not need to specify it two times in the node-creation form. It should suffice to select the parent menu item.

(I find myself retyping the same title again and again...)

So, my suggestion: If only a parent menu item is selected (but no title), then create a menu item with the same title as the node.

Comments

peterx’s picture

Version: 6.x-dev » 6.4

Did this on my 6.4 system, which is the reason I changed the description to 6.4.
Go to page.tpl.php after <?php print $scripts; ?> and add the following without the PHP tags.

  <script type="text/javascript">
$(document).ready(function() {
	$('#edit-menu-link-title').focus(function()
		{
		if(this.value == '')
			{
			this.value = $('#edit-title').val();
			}
		});
	});
  </script>

Notes:
<pre></pre> is not allowed so I used

You could add additional selectors in front of the ids but ids are supposed to be unique and should work everywhere.

A jQuery guru could probably replace the javascript if with something more cryptic.

Some PHP could restrict the inclusion of this javascript to node editing pages.

The code could be in a common javascript file to reduce repeated downloading.

The following addition sets a nice default for URL path settings. It needs a little extra code to change to remove special characters. A superb addition would be the addition of the parent menu structure elements but that is a touch more complicated than I can achieve on the caffeine from one lonely nibble of organic chocolate, even when it is 80% cocoa.

	$('#edit-path').focus(function()
		{
		if(this.value == '')
			{
			this.value = $('#edit-title').val().toLowerCase().replace(' ', '_');
			}
		});
peterx’s picture

The code as a Drupal module. Could be made into a formal Drupal module under the GPL if someone wants to change the one line of PHP to fit Drupal coding standards.
http://d-theme.com/sites/all/modules/pet_menu_default.7z
Documentation:
pet_menu_default sets Menu link title to the same as Title when you select the Menu link title text box. When you select the URL path settings text box, pet_menu_default sets URL path settings to a lower case version of Title with spaces converted to underscores. pet_menu_default uses jquery. Tested in Drupal 6.4 through to 6.9.

aren cambre’s picture

Version: 6.4 » 7.x-dev
Category: task » feature

This is an excellent, commonsense suggestion. It does not make sense that the menu title does not automatically match the page title. This is how things probably work the vast majority of the time.

Moving to 7.x because that's where new features are being added at this time. Hopefully this minor change can be backported to 6.x.

aren cambre’s picture

Status: Active » Closed (duplicate)
Issue tags: +Usability
aren cambre’s picture

Status: Closed (duplicate) » Active

Whoops, didn't mean to mark this as duplicate.

sun’s picture

Status: Active » Closed (duplicate)

Marking as duplicate of #410464: Menu name = node title upon node edit through user interface. You can follow up on that issue to track its status instead. If any information from this issue is missing in the other issue, please make sure you provide it over there.

However, thanks for taking the time to report this issue.

davidmolliere’s picture

Thank you for this peterx, works perfectly !

jonthomas83’s picture

Version: 7.x-dev » 6.13

Sorry to dig up an old post, but is there any way to change the script so that the user does not have to focus on the "menu link title" field.

As it stands now, the code works perfectly, but for my particular needs, I need that field to populate when the "Page Title" field is changed. So I'm guessing that the 'focus' needs to change to 'onChange' somehow.

I've tried but to no avail. If anyone could help that would be great.

peterx’s picture

Something like:
$("#edit-title").change(function() {$("#edit-menu-link-title").val($(this).val());});

My current code lets me select the menu entry then edit the menu entry for those occasions when the page title is too long. The menu entry stays the same short entry even when the page title is slightly changed. An onchange action will replace the edited menu entry. Either way, you have to review the menu entry. I suggest when you use jQuery to change the menu entry, you add code to open the enclosing fieldset.

jonthomas83’s picture

Thank you peterx, very kind of you to help me out so quickly. My aim now is to get on a Javascript course to help me out with issues like this in the future.

Anyway, that worked a treat and does exactly what I needed it to do! Thank you!

EDIT: Would it be worth making this into a module? If someone can guide me in the right direction (as I've never done a drupal module before), I'd be happy to submit it. It's a great piece of helpful functionality that could benefit many.

GingerO’s picture

Thanks for the code snippet, peterx. Worked like a charm, and fast!

peterx’s picture

Try the module at http://petermoulding.com/pet_menu_link_title_default
I added one to set the url path the same way: http://petermoulding.com/pet_url_path_default

jonthomas83’s picture

Peterx - is there a Drupal project page for this? Works a treat!

peterx’s picture

No Drupal project page. I applied for a CVS account on a previous occasion based on converting a Drupal 5 theme to Drupal 6 but it was rejected because I was not planning on supporting the theme beyond the conversion. The theme had existing satisfied users and no outstanding bugs. I was going to convert it and handle conversion issues but not enhance it. Doh! That is not the drupal.org way.