0

Here is the scenario:

We have a D7 multisite set up with an installation profile that we created so that all sites are basically managed with the same rules. But we do allow some flexibility... So we have a content type "News Article". Usually news articles won't be in the menu because there can be thousands of news articles on any given site. One site might want to put their news articles under the "News" menu item in the main menu. Some might call it "News Room". Since we're not forcing the parent path, I can't set "news" as a root path for all the nodes in path auto. And even more crazy, some site users might chose to place node A under News while node B is under About. I was thinking of some type of menu "parent" selector as if they were creating a menu item, without creating the actual menu item in order to generate the path. I thought the menu position module might be on the path I needed, but it turns out you have to create rules administratively and not on a per-node basis where the user is making the determination.

1 Answer 1

0

With the use of the Menu Reference module and hook_pattern_alter, I was able to get this accomplished. The code piece ended up looking like:

function custom_paths_pathauto_pattern_alter(&$pattern, array &$context) {
  if (isset($context['type']) && $context['type'] == 'news_article' && isset($context['data']['node']) && !$context['data']['node']->menu['enabled'] && $context['data']['node']->field_menu_path['und'][0]['mlid']) {
    $menuitem = menu_link_load($context['data']['node']->field_menu_path['und'][0]['mlid']);
    $menupath = drupal_get_path_alias($menuitem['link_path']);
    $pattern = $menupath . '/[node:title]';
  }
}

Your Answer

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

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