1

I would like to create a simple HTML menu made of links to pages A, B, C created in Drupal (but not all pages, only a subset). Unfortunately, menu's in Drupal are displayed as li lists, not just a list of urls, which adds bullets to the display.

A view displayed as unformatted list would be great, but you cannot create a view of miscellaneous page links.

I could create a mini-panel and hardcode the links, but hardcoding is always a bad idea. Ideally, there should be a way to set relative links to pages and let Drupal generate absolute links.

What would be the best way to create a simple a list of links to pages created in Drupal? A block or a mini-panels are acceptable solutions.

1

Using an HTML list is semantically correct in this situation. If you literally want to create a list of links to pages in your site, why would you object to using semantically correct HTML via an intuitive element of site architecture (menus)?

Bullets are a superficial styling default for HTML lists and can easily be removed with CSS.

.block-menu-menu-name ul.menu li {
  list-style: none;
  list-style-image: none;
}

Using the Drupal menu system is still the easiest and most efficient way to create a list of links to pages within your site, even if you do not want to use an HTML list to display them.

You can easily override the theme functions that create any menu's HTML. In your theme's template.php file you can override theme_menu_link() and theme_menu_tree() for the menu you want to manipulate. Let's say the menu is called "Links List".

function THEMENAME_menu_link__links_list($variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<div' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</div>\n";
}

function THEMENAME_menu_tree__links_list($variables) {
  return '<div class="links-list">' . $variables['tree'] . '</div>';
}

Note that there are two underscores before the machine name of the menu in the function name.

This would result in a list of divs with links inside them. Also, you could omit the div wrappers and add a <br /> after each link instead.

It seems like a lot of unnecessary work for what is essentially a superficial styling issue, but perhaps there some other aspect to your overall goal that would make this approach seem more appropriate?

| improve this answer | |
  • Thanks for the detailed answer. I could remove the bullets with you CSS advise. So thanks for that. the underlying li prevents me from aligning the items horizontally. I think, I'll need to create a list manually... – Jérôme Verstrynge Feb 12 '12 at 6:42
  • You can align the items horizontally using a little bit of CSS as well. – sheena_d Feb 12 '12 at 7:55
  • Thanks for the suggestion. I am no expert at CSS. I found display: inline; With this suggestion, I have a complete solution to my issue. I did not know it was possible to achieve this only with CSS. Thanks again. – Jérôme Verstrynge Feb 12 '12 at 8:06
1

You could create a View of miscellaneous page links, if the list of links was actually a list of a series of nodes with a particular taxonomy term applied to them.

For example:

Create a taxonomy vocabulary called "Page Links", and create a new taxonomy term for it called "Custom Menu One". Then, tag each of the pages which you want included in your list of links, with this Custom Menu term.

Now, you can go into the Views UI, and create a block View which outputs all nodes which have the taxonomy term "Custom Menu" applied to them. You can set up the view to use fields, and output the title of each node as a link back to the original content.

You'll also be able to configure the display settings for the View so that the links are output as a List, or Table, or unformatted, etc.

| improve this answer | |
  • Side note, this is an example of how many interesting things can be made possible with Taxonomy, once you wrap your head around it's many possible applications. – David Csonka Feb 11 '12 at 18:42
  • This could work if I created a node type and recreated my pages as such, which is a bit of over-engineering according to me. It is a pity that one cannot add tags to panel pages... – Jérôme Verstrynge Feb 12 '12 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.