Is it possible to group features?

The only reason i have so far for this request is that if multiple features were created improperly...but could possibly prove to be useful in the long run.

A site i'm working has multiple features that could be grouped, and i think that, manually, have to clone views, content types, etc...before creating one big feature that comprises all of the other ones. If i don't clone, i can't reuse the individual CCK and components because Features does not allow them (e.g. a view) to be part of multiple features, and disabling one small feature will remove the content types (along with their CCK fields) from the list.

The opposite, breaking a feature into small ones, could also prove to be useful.

Comments

Grayside’s picture

Priority: Normal » Minor

Once you have created a feature, you can always go in to the feature's .info file and set package = "My Package" this will affect the fieldset it is part of on admin/build/modules, and which section it is in on admin/build/features.

UI in the Create Feature interface to specify the package might be worthwhile.

adamgerthel’s picture

I second this. Grouping features would be a very welcome addition. It's not necessary, but it would make things easier in regards to organizing lots of features

logickal’s picture

+1 to this. We make very granular features, and group them according to site section or functionality by editing the package parameter. I haven't looked yet, but I wouldn't think it would be that hard to expose an optional Package on the Create Feature UI.

logickal’s picture

-Deleting duplicate post-

Grayside’s picture

This is a minor priority, but it's also a minor difficulty. All someone needs to do is add a package UI element to the Create form, and then mimic the same code that places the description or project status url into the feature's .info file.

It should be defaulted to Features, and overridden by whatever is in the feature's .info file. This is probably akin to how the others work already.

hefox’s picture

Title: Group features » Add ability to edit pachage of feature when creating/editing features via the UI
Grayside’s picture

Title: Add ability to edit pachage of feature when creating/editing features via the UI » Add ability to edit package of feature when creating/editing features via the UI
hefox’s picture

Version: 6.x-1.0 » 7.x-1.x-dev
tim.plunkett’s picture

Issue tags: -features

Subscribe.

uniquename’s picture

subscribe

olamaekle’s picture

@uniquename: There's a follow button now ;)

I'm surprised this does not already exist. +1 to this.

dajjen’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta6
Component: Miscellaneous » User interface
Assigned: Unassigned » dajjen
StatusFileSize
new5.74 KB

Me and my friend StoraH (http://drupal.org/user/644948) have created a patch that adds a field in feature admin page for creating feature that lets you add package for you feature.
Please review this patch

hefox’s picture

Status: Active » Needs review
tim.plunkett’s picture

Status: Needs review » Needs work
+++ b/features.admin.incundefined
@@ -46,6 +46,15 @@ function features_export_form($form, $form_state, $feature = NULL) {
+    //'#default_value' => !empty($feature->info['package']) ? $feature->info['package'] : 'Features',

This line looks vaguely correct, but if it's not, remove it.

+++ b/features.admin.incundefined
@@ -340,8 +349,8 @@ function features_admin_form($form, $form_state) {
-      '#markup' => t('No Features were found. Please use the !create_link link to create 
-      a new Feature module, or upload an existing Feature to your modules directory.', 
+      '#markup' => t('No Features were found. Please use the !create_link link to create
+      a new Feature module, or upload an existing Feature to your modules directory.',

Whitespace changes are unrelated, leave them out of this.

+++ b/features.admin.incundefined
@@ -849,4 +858,24 @@ function features_dom_decode_options($options, $keys_only = FALSE) {
+/*
+ * menu callback
+ */
+function _features_autocomplete_packages($search_string) {

See http://drupal.org/node/1354 for proper documentation rules

+++ b/features.admin.incundefined
@@ -849,4 +858,24 @@ function features_dom_decode_options($options, $keys_only = FALSE) {
+  foreach (features_get_features(NULL, TRUE) as $k => $m) {

Don't use single-letter variable names

+++ b/features.moduleundefined
@@ -154,6 +154,15 @@ function features_menu() {
+   $items['davva'] = array(
+    'page callback' => 'davva',

This looks like testing code

+++ b/features.moduleundefined
@@ -889,3 +898,6 @@ function features_hook_info() {
+function davva() {
+  print 'e kung!';

As does this

dajjen’s picture

Status: Needs work » Needs review
StatusFileSize
new3.58 KB

Thank you for your review.
I'v made the changes you pointed out.

Thank you again for your quick respons.

dajjen’s picture

Removed some whitespaces

hefox’s picture

Status: Needs review » Needs work

Thanks, few more things

+++ b/features.admin.inc
@@ -46,6 +46,14 @@ function features_export_form($form, $form_state, $feature = NULL) {
     '#default_value' => !empty($feature->info['description']) ? $feature->info['description'] : '',
...
+    '#default_value' => 'Features',

isn't defaulting for existing features looks like, should be something like : !empty($feature->info['package']) ? $feature->info['package'] : 'Features',

+++ b/features.admin.inc
@@ -46,6 +46,14 @@ function features_export_form($form, $form_state, $feature = NULL) {
+    '#description' => t('Sort this feature into a package'),

Could use a better description; if someone doesn't know what a package is, they won't understand this.

+++ b/features.admin.inc
@@ -849,4 +857,30 @@ function features_dom_decode_options($options, $keys_only = FALSE) {
+ *   The char or string that user have written in autocomplete field, this is the string this function uses for filter.

Over 80 chars; move chars above 80 to next line (see coding standards)

+++ b/features.admin.inc
@@ -849,4 +857,30 @@ function features_dom_decode_options($options, $keys_only = FALSE) {
+function _features_autocomplete_packages($search_string) {

Don't see any reason this needs to be considered a private features function (i.e. underscore at beginning).

+++ b/features.admin.inc
@@ -849,4 +857,30 @@ function features_dom_decode_options($options, $keys_only = FALSE) {
+    array_push($all_features, $value->info[package]);

This is a rather fancy way of doing $all_features[] = $value->info['package']? (missing quotes around package btw),

Annyhow, you foreach gathering all the packages, then you see if they match in another foreach; Seems that can be optimized to a single foreach loops (btw: foreachs are a bit slow, and double btw: don't use foreach ($array as $key => $value when not using $key, it's slower than foreach ($array as $value).

+++ b/features.admin.inc
@@ -849,4 +857,30 @@ function features_dom_decode_options($options, $keys_only = FALSE) {
+    if(preg_match('/'.$search_string.'/', $value)) {

Spacing issues on that concat, '/' . $search_string . '/'

+++ b/features.export.inc
@@ -147,7 +147,7 @@ function features_export_prepare($export, $module_name, $reset = FALSE) {
-  $defaults = $existing ? $existing->info : array('core' => '7.x', 'package' => 'Features');
+  $defaults = $existing ? $existing->info : array('core' => '7.x', 'package' => $export['package']);
   $export = array_merge($defaults, $export);

The array merge takes care of this below; leave this line alone (ie leave package => features there for when package is not set -- ie drush).

dajjen’s picture

Hi, thanks for your respons. I have made this changes you proposed.

dajjen’s picture

changed description of a field

hefox’s picture

Two additions small things from eyeballing (haven't tested the patch yet):

+++ b/features.admin.inc
@@ -849,4 +857,26 @@ function features_dom_decode_options($options, $keys_only = FALSE) {
+    if(preg_match('/'. $search_string .'/', $value->info['package'])) {

The coding standards changed in d7 for concat spacing, it's now '/' . $search_string . '/', ie have a space on each side of the period.

+++ b/features.module
@@ -154,6 +154,12 @@ function features_menu() {
+    'access arguments' => array('user_access'),

This should be access arguments => array(whatever the relevant permission is) [don't have features.module open atm to look]). Don't need an access callback (you didn't add one, but since the access argument was referencing an access callback, figured I'd mention that. Access callbacks default to user_access).

Thanks!

dajjen’s picture

Status: Needs work » Needs review
StatusFileSize
new3.53 KB

Hi and thanks again for all your help.
I hope I have made the necessary changes to this patch.

misc’s picture

Status: Needs review » Reviewed & tested by the community

I have tested the patch and it works great for me on 7.x-1.0-beta6.

Just a note - I mark as RTBC, but I work as the same company as @dajjen, so that is a problem, please swtich back to needs review.

Grayside’s picture

Category: feature » support
Status: Reviewed & tested by the community » Fixed
Grayside’s picture

Category: support » feature
Status: Fixed » Reviewed & tested by the community

Ooops. I thought I was on a completely unrelated issue in the OG queue. Sorry.

dajjen’s picture

Status: Reviewed & tested by the community » Needs review
zilverdistel’s picture

Status: Needs review » Needs work

Works for me ...

+++ b/features.admin.incundefined
@@ -46,6 +46,14 @@ function features_export_form($form, $form_state, $feature = NULL) {
+    '#required' => TRUE,

Not sure if we should require a value for this field ...

Nice work with the autocomplete too! Thanks!

zilverdistel’s picture

Status: Needs work » Reviewed & tested by the community
mpotter’s picture

Removed the Required flag. Committed 6b4b87c

mpotter’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

nancydru’s picture

Status: Closed (fixed) » Patch (to be ported)
Issue tags: +needs backport to 6.x

Please back port to 6.x.

tim.plunkett’s picture

Version: 7.x-1.0-beta6 » 6.x-1.x-dev
Assigned: dajjen » Unassigned
Priority: Minor » Normal

  • mpotter committed 6b4b87c on 8.x-3.x
    Issue #1058778 by dajjen | nymo: Added ability to edit package of...