Add NodeSymlinks support to Menu Node API.

Comments

l0ke’s picture

This patch makes Menu Node API work with NodeSymlinks.

gabriel.achille’s picture

Status: Active » Needs review

change status for automated test.

gabriel.achille’s picture

Status: Needs review » Postponed (maintainer needs more info)

I'm not a fan of having module-specific logic in here. And why did you need to modify an old hook update function for drupal 6 in this patch (menu_node_update_6003) ?

l0ke’s picture

The changes if menu_node_update_6003 wasn't the point but it can be used for Drupal 6 NodeSymlinks support.
Yes, it has some NodeSymlinks specific router_path, but is also faced the problem that str_replace('node/', '', $link['link_path']) doesn't work correctly if link path contains trailing slash, and using preg_replace('/(node\/)([\d]*)(.*)/', '$2', $link['link_path']) solves this problem.

l0ke’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review
dgtlmoon’s picture

Status: Needs review » Closed (duplicate)

This looks to be a duplicate of #1691508: Install fails with exception

bohemier’s picture

Thanks for the patch. Works fine here. With this patch, when creating a node Symlink, the Menu Node API table gets also updated, so the symlinks can be retrieved with Menu Node Views to get the proper menu structure. Please consider merging...

cameron prince’s picture

Status: Closed (duplicate) » Needs work

This issue is related to #1691508 in that it seems to include the same fix, but it does more.

The problem is that nodesymlinks don't get their own row in the menu_node table this module provides. The views filters provided by Menu Node Views rely on this table and will never display menu items that don't have a row there.

I applied this patch and it does solve the problem for newly created nodesymlinks. Unfortunately, it's not working retroactively, i.e. existing nodesymlinks aren't added to menu_node.

bohemier’s picture

Yes, I had to recreate the missing db entries... Perhaps this can be done with the schema version?

cameron prince’s picture

Here's a quick command-line script to create the rows for existing nodesymlinks.

#!/usr/bin/php -q
<?php

  $db_connection = @mysql_connect('localhost', '<username>', '<password>');
  if (!$db_connection || !@mysql_select_db('<database>', $db_connection))
    die ("Unable to connect or select database.\n");

  $result = mysql_query("SELECT link_path FROM menu_links WHERE module = 'nodesymlinks'")
    or die(mysql_error());

  while ($row = mysql_fetch_array($result))
  {
    $link_path = $row['link_path'];
    $link_path = preg_match('/node\/(\d+)\/mid\/(\d+)/', $link_path, $values);
    $nid = $values[1];
    $mlid = $values[2];
    mysql_query("INSERT INTO menu_node VALUES ($nid, $mlid)")
      or die(mysql_error());
  }