Hello,

So, I have pathauto enabled, and I am going through the motions of setting up a really simple website where the account_admin can made new nodes, and assign them to the primary menu all on their own, from the node creation screen.

When they type in the box the menu title [say the name is: 'foobar'], and the checkbox for "create pathauto alias' is on, I get the following result:

-=-=-
Menu item:

Title: foobar
Path: node/8

Alias created:

Alias: content/foobar
Path: node/8

-=-=-

The alias works, but the problem is, that the menu item should have in it:

Title: foobar
Path: content/foobar

and NOT

Path: node/8

As this completely defeats the point of making an alias... because the entire menu has in it numbers instead of alias's...

Is this just a bug [oversight] in path auto & the menu system?

Or do I need to turn "on" something that is not on by default to get it to work?

Thanks for your help!

Sebastian.

Comments

schedal’s picture

hello, still wondering if anyone can provide some insight, is this a limitation in pathauto? Or do I need to change some other config to make this work? Your help is really appreciated; thanks!

greggles’s picture

When you create a menu entry the "Path" used in the menu entry should generally be the internal system path like "node/8". This keeps Drupal consistent if the alias for node/8 changes later on.

The important part: when menu items are displayed Drupal should change them from the "node/8" format into whatever their alias is. If your site doesn't do that then there is a bug somewhere in your site. Are you using any other modules or a custom theme?

schedal’s picture

Hi, there is indeed something odd going on, because the site's menu links do not change to match the pathauto-link names.

The theme is a custom theme, which is very simple, but I did build it from scratch -- so that it would match one-to-one the design that they were using before I converted their website into drupal [before that it was a simple HTML+PHP site], and I am indeed using other modules beyond core, but nothing exceptional IMHO.

Would it be helpful for me to post what modules I am using?

Or is there something in my custom theme that I need to include, to permit the path-auto links to appear instead of the hard-coded ones? On that note: I am generating my menu using the following code:

<?php	foreach ($primary_links as $link): ?>
    
    	<?php	
		 			
            		$class = '';
					
					if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page())) && (empty($link['language']) || $link['language']->language == $language->language)) {
					$class .= 'active';
				    }
					  print '<p class="pbullet">';
             		
					$href = $link['href'] == "<front>" ? base_path() : base_path() . $link['href'];  
				   
				   
				   	print "<a class='". $class . "' href='" . $href . "'>" . $link['title'] . "</a></p>"; 
					 $i++;
			 ?>
    
    <?php endforeach; ?>

The code is written in this way, so that the resulting HTML is identical to how it was pre-Drupal, so that there were in actuality zero required CSS changes needed after the porting.

Could this be the problem?

Thank you kindly for your help!!

Sebastian.

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

What are your node alias patterns from admin/build/path/pathauto?

schedal’s picture

Status: Postponed (maintainer needs more info) » Active

Hi Dave, nothing has changed from default, it lists:

content/[title-raw]
dave reid’s picture

I think
$href = $link['href'] == "<front>" ? base_path() : base_path() . $link['href'];
should be using:
$href = url($link['href']);

That way it will auto-alias the link for you. Also takes care of <front>

greggles’s picture

Status: Active » Fixed

Or even turn:


                    $href = $link['href'] == "<front>" ? base_path() : base_path() . $link['href']; 
                  
                       print "<a class='". $class . "' href='" . $href . "'>" . $link['title'] . "</a></p>"; 

Into this:


print l($link['title'], $link['href'], array('attributes' => array('class' => $class)));

Which has the benefit of doing a check_plain on the $link['title']. This is in the README.txt, btw.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

schedal’s picture

Assigned: Unassigned » schedal
Priority: Normal » Minor
Status: Closed (fixed) » Needs review

Thank you both for your replies! Sorry for my slow response, other projects were usurping my time. Much appreciated Dave and Greggles!

BTW my PHP code was an edited version I grabbed from a theme (I think it was Nitobe, but I could be wrong) -- my bad for not verifying if they were using Drupal compliant syntax standards.

greggles’s picture

Priority: Minor » Normal
Status: Needs review » Closed (fixed)

Great, thanks for the feedback.