wrong menu declaration
kiamlaluno - August 12, 2008 - 16:40
| Project: | EveryBlog |
| Version: | 6.x-2.0-dev0001 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | by design |
Jump to:
Description
The first menu item defined uses a translated string for the array index, which is supposed to be a string that is constant at the variation of the language set by the Drupal administrator.
The following code should be changed from:
<?php
// Show a list of all blogs
$items[t('blogs')] = array(
'title' => 'Blogs',
'page callback' => 'everyblog_list_blogs',
'access arguments' => array('access content'),
'type' => MENU_SUGGESTED_ITEM,
'file' => 'everyblog.pages.inc',
);
?>to:
<?php
// Show a list of all blogs
$items['blogs'] = array(
'title' => t('Blogs'),
'page callback' => 'everyblog_list_blogs',
'access arguments' => array('access content'),
'type' => MENU_SUGGESTED_ITEM,
'file' => 'everyblog.pages.inc',
);
?>I would then suggest to replace the tab characters used in the code with a couple of plain spaces, like the documentation of Drupal says to do.

#1
I was playing around with using translated strings as paths. It would work fine for a site in a single language regardless of the language. But I'll go back through and remove them.
As for the tabs vs spaces. I guess if Drupal says spaces I'll use spaces. Though I'm firmly a tab guy since any editor worth anything can configure how wide tabs appear. And spaces are just a pain, because most editors will insert spaces with from the tab key but very few will delete spaces as if they were a tab, which means that you need double the deletes to undo indention. I've never understood what people have against tabs, its like someone decided, hey, I don't want to be like everyone else so lets setup a camp that is fervently spaces and denounce tabs, just to be cantankerous. Anyways, that's the end of that rant, lol.
#2
In the array which defines the menu items used by a module, the array index is a constant string because, in the case you change the language for the Drupal-powered web site, the definition of the menu items will not appear duplicated for every language which has been set in the web site.
After all, what the users see is just the menu title, or the description, not the index used in an array.
I don't have anything against tabs. It's just that, using different editors in different operating systems, the indentation is showed differently when using the tabs.
I know that using spaces can be a pain, in some occasions. I don't notice that because I use an editor which, when I press the backspace, deletes the number of spaces I set like indentation; when I move using the cursor arrows, it moves the cursor by the amount of spaces I set like indentation (if the characters near the editing cursor are spaces).
The Drupal coding standards don't give an explanation of the choices made, unluckily, so sometimes it's hard to accept them.
#3
Menu titles, and descriptions don't need to be passed to
t()because that is already done from Drupal core code; what I reported here is not valid with the latest Drupal 6 version.