Simple Title in Nav Menu

Simple question, but I can’t find any documentation on how to implement the following.

How do I have a simple link in my main navigation to a page with a more “meaningful” title. For instance, I would like a page title to be “Biography of Clinton W. Gray”, but the nav should just be “BIO”.

I would introduce a new field in the blueprint, e.g. menu_title and fetch that for the menu instead of the title.

Right, thanks. I thought about something like that, but it seemed complicated for the use case. I thought there might be a “slug” or something similar in the API.

Yes, there is $page->slug().

Edit: You could use either ucfirst() or strtolower() on the page slug.

ucfirst($page->slug());

to make the first character of the slug uppercase.

Thanks. I’m playing with that now, but it’s not exactly doing what I wanted. The issue is the $page->slug only gives me the slug of the page, not of all the pages ( children()->visible() ) for the nav. Your blueprint suggestion seems the best route. Will mark solved once I have it working.

Could you post your code? Of course you have to use the method within your foreach loop …


<?php
foreach($page->children()->visible() as $child) {
  echo ucfirst($child->slug());
}
?>

Solved! I was doing:

$item->slug()->html()

and getting function html() on a non-object error.

Once I removed html() everything worked great. Thanks for your help!