1

I have a Drupal Menu which I created through the interface. I wish to add an entry which says

Hi, John Doe

Where "John Doe" is a link to the User's profile page. I would like to do this programmatically or if it can be done through the interface then that would be great.

1 Answer 1

0

You cannot add HTML-ified items to the menu. Menu-items are always wrapped in an anchor tag and will filter out HTML. Changing this behaviour is technically possible, but will cause a lot of unknown side-effects.

What you want, is either a simple theme override, or a custom block (potentially without a title and with some other bullets).

You can create a block with hook_block or by simply typing the HTML, with some PHP into a new block, using the PHP-input filter. This last option is quick, but is discouraged by many people for performance and "good practices" reasons: you should not store php in your database.

EDIT: After comment about "just the name":

To insert "just the name" you simply need to create module with a hook_menu.

global $user;
$items['path/%uid'] = array(
  'title'            => $user->name,
  'description'      => 'description',
  'page callback'    => 'drupal_get_form', //Fill in the callback here: function that renders the page content.
  'page arguments'   => array(''),
  'access callback'  => '',
  'access arguments' => array(''),
  'weight'           => 0,
  'menu_name'        => 'Navigation',
  'type'             => MENU_NORMAL_ITEM,
);

Is about what you want.

Sign up to request clarification or add additional context in comments.

1 Comment

OK, understood. I need the client to have the ability to control the menu. How about just a link to the name, e.g. Ed Henderson

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.