Comments

bmx269’s picture

Are asking to have the settings exportable with Features?

adrianmak’s picture

Yes, exactly.

bkoether’s picture

Good idea adrianmak,

I will add it to the roadmap.

Ben

bkoether’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Assigned: Unassigned » bkoether
Category: support » feature

Top priority for version 1.2

bkoether’s picture

Hope to have that in 1.3. Sorry for the delay on this feature request.

BarisW’s picture

Title: Does Features module support ? » Implement Features integration

Hi Benjamin,

this is on the roadmap for a few months now. Any news yet? You've assigned the issue to yourself, which means that others won't work on it as they expect you to do it. Are you working on this? If not, I am willing to implement it.

Please let me know it you need any help.

bkoether’s picture

Assigned: bkoether » Unassigned

Hi BarisW,

Life and work has me booked up quite a bit at the moment. So any help on this would be welcome.
I didn't had the time yet to start on this at all but my plan was to use CTools in order to create exportables (http://drupal.org/node/928026).

Really would appreciate your help with this!

BarisW’s picture

Assigned: Unassigned » BarisW

Hi Benjamin,

no problem. I'll have a look. There is one drawback for using Ctools: all links must be identified using a system name. Which means the schema should be altered and a system name should be implemented (including in the interface). This is why Views, Rules, Context etc all use system names.

It is possible without using system names, but then the feature integration should be done manually, not using Ctools. I've wrote a blog about this: http://www.bariswanschers.com/blog/exporting-your-module-configuration-u...

I'll post a patch within a week or so.

BarisW’s picture

Status: Active » Needs review
StatusFileSize
new3.25 KB

Hi Benjamin,

here's a first patch. Features is working with this patch. I didn't implement the Ctools way, but the good old Features way. Te define whether a configuration is overridden, there should be a unique identifier, other than an ID (as said before). In my patch, I used the Title as key, which works in most use cases. However; the interface doesn't restrict you from using the same Title twice, and then the Features integration won't work.

So two things can be done:

  1. Add a system name for each configuration and store this in the database. This means:
    1. Let the user choose a system name (might be auto-generated by using the title)
    2. Validate on double system names
    3. Add the system name to the database using a hook_update()
  2. Leave the title as unique key, but validate on submitting the admin form.

Please test.

BarisW’s picture

I've improved it a bit more by adding a 'machine name' column that is used as unique identifier.
This patch implements te following:

  • Add a 'name' column to the database table
  • Fill the name column with default names ('link_1', etc) so it can be made unique
  • Make the name column unique
  • Add features integration using the name column

Please test and let me know if it all works as expected ;)

BarisW’s picture

By the way Benjamin. If you want, you may make me co-maintainer as well so I can help you with future development of this magnificent module. If you do, I can commit this patch myself.

mojzis’s picture

Baris, i failed to apply the patch :( is there anything special about it ? thanks

Checking patch ccl.admin.inc...
error: while searching for:
    '#required' => TRUE,
  );

  $form['link_group']['ccl_link'] = array(
    '#type' => 'textfield',
    '#title' => t('URL'),

error: patch failed: ccl.admin.inc:119
error: ccl.admin.inc: patch does not apply
Checking patch ccl.features.inc...
error: while searching for:

error: patch failed: ccl.features.inc:0
error: ccl.features.inc: patch does not apply
Checking patch ccl.install...
error: while searching for:

  module_enable(array('ccl_blocks'));
}

error: patch failed: ccl.install:124
error: ccl.install: patch does not apply
Checking patch ccl.module...
error: while searching for:
  return $items;
}

/*
 * Implements hook_contextual_links_view_alter().
 *

error: patch failed: ccl.module:59
error: ccl.module: patch does not apply
BarisW’s picture

Hmm, weird. I've tried creating a new patch using git diff. Can you check if this one works?

mojzis’s picture

still not. maybe i am doing something wrong ? i cloned master, is that where you started ?

could you be one commit ahead or something ? i dont have the features file at all. menu hook stops at 55 while you have it at 59

Checking patch ccl.features.inc...
error: ccl.features.inc: No such file or directory
Checking patch ccl.install...
Checking patch ccl.module...
error: while searching for:
return $items;
}

/*
* Implements hook_contextual_links_view_alter().
*

error: patch failed: ccl.module:59
error: ccl.module: patch does not apply

BarisW’s picture

Ah, I think I found what went wrong. I've should used git diff HEAD instead of git diff.
This one should work.

mojzis’s picture

the features file is OK now, but ccl.module is still a problem. can you please check why your ccl_menu ends @ line 59 ? here : http://drupalcode.org/project/ccl.git/blob/HEAD:/ccl.module its at 55 ...

sorry for all the trouble and i am really looking forward to testing this :)

BarisW’s picture

Weird. I didn't changed the hook_menu logics, only applied Drupal coding standards.

I've removed the unneeded single line on 14 and added on extra line on 56.
Maybe you can try and add the code manually? The module only needs these two extra functions:

</php

/**
 * Implements hook_features_api().
 */
function ccl_features_api() {
  return array(
    'ccl' => array(
      'name' => 'Custom Contextual Links',
      'file' => drupal_get_path('module', 'ccl') . '/ccl.features.inc',
      'default_hook' => 'ccl_features_preset',
      'feature_source' => TRUE,
    ),
  );
}

function ccl_get_presets($title = NULL) {
  $presets = array();
  if ($title) {
    $results = db_query('SELECT * FROM {ccl} WHERE title = :title;', array(':title' => $title));
  }
  else {
    $results = db_query('SELECT * FROM {ccl};');
  }

  while ($result = $results->fetchObject()) {
    $presets[] = $result;
  }
  return $presets;
}
?>
bkoether’s picture

Status: Needs review » Fixed

Thanks BarisW for providing this patch.
And sorry that it took so long for me to test it and to add it to the dev branch.

Committed to 7.x-1.x-dev, will be in 7.x-1.3 (release next week).

BarisW’s picture

Sweet, thanks. Next time, would you be so kind to add Proper Git Attribution, so the commit ends up on my Profile? :)

bkoether’s picture

Sorry... I referenced you in the commit message but forgot about the --author flag.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.