There seems to be some issues with aggregator menus. Using paths:

  1. aggregator shows a list of posts with the title "news aggregator" and breadcrumbs (bc) limited to "Home", no local tasks
  2. aggregator/categories shows a list of categories and their most recent posts, with bc Home > news aggregator
  3. aggregator/categories/<cid> shows a visually identical list of posts with the same title as in (1), the same bc as in (2), and local tasks, but no title or mention in the bc about the current category
  4. This seems inconsistent: it seems that

  • (1) should have the local tasks
  • (2) is correct
  • (3) should have bc including a link to level (2) and a title containing the current category

Otherwise we're missing consistency.

Note: this is carried over from http://drupal.org/node/172835

Comments

chx’s picture

Status: Active » Needs review
StatusFileSize
new1.83 KB

This little patch might help one of your cases. Also apply please http://drupal.org/node/172754 it might help some others if not, please patch.

fgm’s picture

StatusFileSize
new5.2 KB

I did some additional fixing for (3). The suggested patch combines this with the previous patch.

However... I'm under the impression that the new menu system might have made this change unnecessary:

// in aggregator.pages.inc/aggregator_page_category :

drupal_set_breadcrumb(array_merge(drupal_get_breadcrumb(), array(l(t('Categories'), 'aggregator/categories'))));
drupal_set_title($category['description']);

Couldn't it be replaced by some additional parameters in aggregator_menu ?

I did not define the local tasks at aggregator because I'm not sure what they should be:

  • titles of existing categories ? But if this is chosen, the number of tabs could be impractically high. And should empty categories be pruned ? Actually, I'd rather add a link to the single child page "Categories", which is the one from which one can come back to this page: all the other links just skip it, providing no means of access to this page's only child, which is a UI problem
  • View | Categorize | Configure ? But if so, this might be disturbing for users to find the same tasks at two difference levels, and not applying to the exact same selection of news items.
chx’s picture

I would say let's do what D5 does. My patch strives to get there.

fgm’s picture

StatusFileSize
new5.1 KB

In that case, it should be drupal_set_title($category['title']); instead of drupal_set_title($category['description']);

Modified patch accordingly.

chx’s picture

StatusFileSize
new2.52 KB

osinet, I have problems with your patch. I have rerolled mine with your drupal_set_breadcrumb call, but I do not see what else have you changed. The drupal_set_title in aggregator_page_category has the wrong index and also, there is a title callback to set up the title so why do you need a drupal_set_title?

pwolanin’s picture

subscribe

fgm’s picture

You're right to have a problem with my version: the menu_set_title wasn't needed after all, it seems. The only other changes were the drupal_set_breadcrumbs and some reordering in aggregator_menu to make the source more easily readable (ordering menu definitions for foo, foo/bar/baz, and foo/bar/baz, and foo/bar/baz/qux in that order instead of having them unordered and interspersed with other paths.

Your version is good for me. RFCR.

chx’s picture

Title: Inconsistent titles and breadcrumbs at various levels in aggregator » Breaker: aggregator category menu got lost
Priority: Normal » Critical
StatusFileSize
new2.52 KB

My aggregator cleanup from a time ago caused this -- I was aware of the problem so I have readded the menu links in here but the issue title is nowhere near appropriate, the breadcrumb fix is a minor fix compared to the rest of the patch.

gábor hojtsy’s picture

Why, oh why do we need to fiddle in the menu table in aggregator module?

chx’s picture

StatusFileSize
new3.51 KB

As promised in the menu comment if this gets in, i will love a bit node_menu too.

chx’s picture

Let me mention this is does not simply restore the category menu but by moving from router to links, it will scale easily to hundreds or thosuands of feeds.

chx’s picture

StatusFileSize
new3.51 KB

huh i has written ['cid'] in the delete instead of ['mlid']

chx’s picture

StatusFileSize
new3.54 KB

This is much cleaner: we use the module field.

pwolanin’s picture

typo in the code comment here: "Get an link by its path and the hadnling module."

also, would it not make more sense to call it function menu_link_load_by_path rather than function() menu_link_load_by_module() since module is an optional parameter?

catch’s picture

StatusFileSize
new3.51 KB

this fixes the typo. Also added a full stop at the end of another comment. Don't credit etc.

chx’s picture

StatusFileSize
new4.01 KB

Your patch did not apply. I have rolled from mine. To clarify, I simply removed the module default. There is no point in menu_link_load_by_path as the return of such a thing can not be defined because a path does not define a menu link, one path can have many links. Adding a module constraint makes it meaningful.

pwolanin’s picture

@chx - the result may still not be unique, even with the module constraint. Also, since we only want one result, it may be better to use db_query_range(). Also, we may not want to use m.*, since some fields in {menu_links} and {menu_router} have the same name. I think with MySQL the below may work correctly (i.e. the ml. fields clobber the m. fields, but that may be db-specific - is there an ANSI SQL standard for this issue?)

Actually - this is probably something that needs to get fixed in menu_link_load() as well (so maybe this code is my fault). I think the code here is more correct: http://api.drupal.org/api/function/menu_tree_page_data/6

something like:


function menu_link_load_by_module($path, $module) {
  if ($item = db_fetch_array(db_query_range("SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.* 
                   FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path 
                   WHERE ml.module = '%s' AND ml.link_path = '%s'", $module, $path, 0, 1))) {
    _menu_link_translate($item);
    return $item;
  }
  return FALSE;
}

chx’s picture

StatusFileSize
new4 KB

"Menu system is cool", Episode N: "do what I mean" featuring menu_link_maintain. Just does what needs to be done.

dmitrig01’s picture

+ *   The path this link points to.
+ * @param $Link_title
+ *   The title of the link. Unused for delete.

Shouldn't link_title be lowercase?

chx’s picture

StatusFileSize
new4 KB

Of course it needs to be and what stopped you from fixing the patch -- you surely had the time if you had the time to discover such an earth shattering bug :/ if I am not here after hours then this would have held up the patch totally absolutely needlessly.

dww’s picture

Code in #20 mostly looks fine to me. I didn't try testing it, but it's clear and well-documented. 1 tiny nit-picking problem: "uncostumized" is a typo in a phpdoc comment. No time to re-roll myself, and it's not worth setting this to CNW over a typo in a comment. menu_link_maintain() looks like a nice improvement. Other than the typo, and oh, yeah, testing it, ;) I'd mark this RTBC...

JirkaRybka’s picture

StatusFileSize
new4 KB

I just grabbed a text-editor and edited the previous patch file for that typo in #21...

chx’s picture

Status: Needs review » Reviewed & tested by the community

I am setting this to RTBC -- I know it works and I am fairly sure the core commiters will like the "do what I mean" approach.

chx’s picture

StatusFileSize
new3.54 KB

Further testing revealed a notice thrown on delete.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed
StatusFileSize
new4.04 KB

OK, fixed the phpdoc for the menu link maintain function.

Before:

+/**
+ * This function helps your module maintains its links.
+ *
+ * It will insert, update or delete an uncustomized link belonging to a
+ * certain module pointing to the given path.
+ *
+ * @param $module
+ *   The name of the module.
+ * @param $op
+ *   insert, uodate or delete.
+ * @param $link_path
+ *   The path this link points to.
+ * @param $link_title
+ *   The title of the link. Unused for delete.
+ */

After:

+/**
+ * Insert, update or delete an uncustomized menu link related to a module.
+ *
+ * @param $module
+ *   The name of the module.
+ * @param $op
+ *   Operation to perform: insert, update or delete.
+ * @param $link_path
+ *   The path this link points to.
+ * @param $link_title
+ *   Title of the link to insert or new title to update the link to.
+ *   Unused for delete.
+ */

"This function" was pointless. We never tell something to the developer (ie. your module) and maintain was already in the function name, so it was not helpful. There was a typo in the op list and the link title missed explanation on how it is actually used. Now committed this patch.

chx’s picture

Title: Breaker: aggregator category menu got lost » menu_link_maintain needs to return the mlid of the inserted menu entry
Priority: Critical » Normal
Status: Fixed » Reviewed & tested by the community
StatusFileSize
new905 bytes

This is an absolute no brainer.

dww’s picture

Agreed. +1 on the basic change.

Not sure how i feel about return; break; right after each other like that.

+ the break is more consistent and defends us from a bug in the future if someone re-factors where the return happens
- the break isn't necessary as it currently stands

In the interest of defensive programming, I'm happy to leave it how it is, so I'm not changing this from RTBC, but I wanted to at least raise the point. Not sure if there's existing precedent in core on how to handle this.

Thanks for continuing to make Drupal better, chx. ;)

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

I think having the break there is good for code cleanliness and consistency. So committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)
mcsnolte’s picture

StatusFileSize
new46.29 KB

The addition of "drupal_set_breadcrumb" in "modules/aggregator/aggregator.pages.inc" seems to possibly mess up the breadcrumbing.

See attached screen shot of "Categories" being duplicated.