This would be great to integrate with the Features module. I have a Feature of news item content type with a vocabulary, a view with multiple displays, image styles, a menu item and the icing on the cake would be a menu position rule.

Comments

Shadlington’s picture

+1

vectoroc’s picture

+2

mstrelan’s picture

Status: Active » Needs work

I've never integrated with Features before but it seems like it should be pretty easy using the CTools Export API. Here's what I've got so far.

Allow rules to be exported using Features.

<?php
function menu_position_schema() {
  $schema['menu_position_rules'] = array(
    'description' => 'Stores breadcrumb rules for nodes.',
    // CTools export definitions.
    'export' => array(
      'key' => 'admin_title',
      'primary key' => 'rid',
      'identifier' => 'rule',
      'default hook' => 'default_menu_position_rule',  // Function hook name.
      'api' => array(
        'owner' => 'menu_position',
        'api' => 'default_menu_position_rules',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),  

    // Some code truncated .............
?>

This is all well and good for exporting a rule, although it should really save machine names.

I have no idea how to get the rules to import when you enable the feature. Executing this PHP seems to do the trick though.

<?php
ctools_include('export');
foreach (ctools_export_crud_load_all('menu_position_rules') as $rule) {
  ctools_export_crud_save('menu_position_rules', $rule);
}
?>
acbramley’s picture

sub

crashtest_’s picture

StatusFileSize
new6.12 KB

Here is a big start on making this features-able.

There is an issue, #1001538: Provide CRUD functions for menu position rule sets, which will be about getting crud features into menu_position, and this issue will need to use that groundwork when it is complete.

Currently this patch will export a feature, and setup the schema (including updating current db's). It will not work correctly for updating on different machines and evaluating between code and db, as the crud features aren't in place. It's a start though.

dave reid’s picture

Title: Features integration » Add CTools exportable support for menu position rules
johnalbin’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

Moving to 7.x-2.x.

johnalbin’s picture

Before calling ctools_export_load_object(), you need to this first:

ctools_include('export');
bforchhammer’s picture

Any news on this issue? Is this still waiting on co-maintainership for Dave Reid and CrashTest_?

zhgenti’s picture

It would be really great if you guys could add this feature.

mattiasj’s picture

Would love too see this as well. Menu position is an important feature for almost any site produced.

BarisW’s picture

John, do you need any help here? What's the status?

phayes’s picture

Assigned: Unassigned » phayes

I'm going to be taking a crack at this.

phayes’s picture

Assigned: phayes » Unassigned

Ugh,

I just realized a major problem with the whole idea of making menu-position rules exportable. Menu position rules need to reference a "parent" menu-link item, but Drupal does not provide an exportable machine-name for menu links. All menu-links are merely ID'ed using auto-incrementing INTs. So actually "referencing" a menu-link, and expecting it to work across sites where we've also exported the menu using features, isn't going to work.

Anyone have any thoughts on this?

mraichelson’s picture

UUID has some code in it that will add something more unique to menu links for exporting to features. Might be worth taking a look at.

socialnicheguru’s picture

there is also defaultconfig which might be helpful

socialnicheguru’s picture

I got the following when I applied the patch:

Warning: unserialize() expects parameter 1 to be string, array given in menu_position_evaluate_rules() (line 284 of modules/all/menu_position/menu_position.module).
Warning: Invalid argument supplied for foreach() in menu_position_evaluate_rules() (line 285 of /menu_position/menu_position.module).

pvhee’s picture

Any progress on this issue since 2012?

netsensei’s picture

#14 is right. Without proper uuid support, exporting/importing menu position rules is going to be quite the exercise.

I would recommend postponing this to a 8.x branch. Why?

1. Because the core menu_link module in D8 (and, by extent, entities in D8 in general) supports UUID's of the box.
See: https://api.drupal.org/api/drupal/core%21modules%21menu_link%21menu_link...

2. Because relying on UUID from contrib would introduce another dependency which needs to be maintained.

WS_vanessa’s picture

Issue summary: View changes

subscribe

jmking’s picture

@netsensei - this could be created as a sub-module. That's what most modules do that do not want to enforce a dependency on UUID, but still want to offer features compatibility.

antondavidsen’s picture

joachim’s picture

Status: Needs work » Closed (duplicate)

Closing as a duplicate.