The Computed Field Order module helps to deal with the situation of fields
being computed in the order in which they are found in the "field_config_instance"
database table. Since that table is largely populated in the order in which you
add fields to an entity, one may control the order of computation by adding
fields in the order desired. Occasionally, however, it may be necessary to
have a later-added field computed before an existing field, such as when a field
containing data must be deleted and re-added. The easiest solution to this is to
delete and redefine the subsequent fields, thereby preserving the database integrity.
But if there are a lot of uses of that field and re-saving the content is difficult,
then this module may help you restore the desired computation order.

If there is any way to take the manual solution above, we reccommend doing so.
You are strongly urged to back up your database before using this module.
We also suggest testing your site after using it, particularly the fields you
are altering.

* Install and enable the module in the usual manner.
* Back up you database (optional, but reccommended).
* Go to admin/config/content/computed_field_order
(Configuration >> Content authoring >> Computed Field Order).
* Click on the bundle type that needs to be changed.
* Drag the field handles to the order you want.
* Click on the "Change order" button.
* Test to make sure the correct effect has occurred.

You may disable the module when it is not in use so that it
is not loaded at every page build.

Link to sandbox Project
https://drupal.org/sandbox/ssoulless/2187993

Git clone command line
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/ssoulless/2187993.git computed_field_order

CommentFileSizeAuthor
#13 computed_field_order.png3.8 KBpushpinderchauhan

Comments

hayashi’s picture

Hi @ssoulless

Please add link to your git repository.

I found issue in computed_field_order.info.
dependencies = computed_field
should be
dependencies[] = computed_field

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxssoulless2187993git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

ssoulless’s picture

Hello, so I just need to correct the problems and then put the needs review state again? or I should create another issue?. Thanks

dsim’s picture

Hi,

Just fix the issues and commit it and update the same issue with "Needs reviews" state.

Also add the "git clone" command in issue summary.

Also please take care of the following:
In module file, line 106,
"admin/config/content/computed_field_order/$row->entity_type/"

It can be better if you use the variables out of double quotes using concatenation.

Thanks

ssoulless’s picture

Ok I will. Thanks

ssoulless’s picture

Issue summary: View changes
PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application (see also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

ssoulless’s picture

Assigned: Unassigned » ssoulless
Status: Closed (won't fix) » Needs review

Hi I just commited the changes, please review them. I think I can maintain the module now would be great if I can create the project, I have the module working in one of my production sites and is working great =)

Thank you

Sachini’s picture

Manual review of the 7.x-1.x branch:

The git clone command should be "git clone --branch 7.x-1.x http://git.drupal.org/sandbox/ssoulless/2187993.git computed_field_order" as it appears in your sandbox. The command you have given is for you, with maintainer access.

computed_field_order.module

  • line 10 : Error: Undefined variable info
Sachini’s picture

Status: Needs review » Needs work
ssoulless’s picture

Status: Needs work » Needs review

Ok link command fixed.

and for the problem of the $info variable please check the comments above that line.

ssoulless’s picture

Issue summary: View changes
pushpinderchauhan’s picture

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

@ssoulless, first of all thankyou for your contribution.

Manual Review
1. (*) You have keep all your code inside .module file, for configuration form create one separate file something like computed_field_order.admin.inc.
2. I installed your module and access the admin/config/content/computed_field_order page but as I don't have added any computed field so no bundle is appearing there. But it is still showing Click on a bundle name to expose the computed fields for that bundle.. I think this message should appear when $items count is > 0.
3. After this I created one computed field inside article content type and access this page, it is still showing me same screen without any change. Then I manually check admin/config/content/computed_field_order/node/article page, it showed me computed field. It need to be fixed as end user not able to understand how computed field would appear.
4. Let me check by adding one more computed field in page content type, now its a strange issue it is appearing as:

Computed Field

Let me check your $item array,

Array
(
    [node] => Array
        (
            [data] => Node
            [children] => Array
                (
                    [page] => Array
                        (
                            [data] => Basic page
                            [class] => Array
                                (
                                    [0] => computed_field_order
                                    [1] => node
                                    [2] => page
                                )

                        )

                )

        )

)

Strange, it also showing me only one content type name i.e page. Article content type still not in array.

Interesting, I need to debug your code because I am still able to see computed field in Article content type. There is some major logic failure in following code. Every time first it goes to else statement because $items array is always empty and inside your else statement there is no link added for bundle. This is the problem that you need to fix in a good manner because your first element always skipped due to this else statement.

foreach ($result as $row) {
    // Build a multi-level list.
    if (isset($items[$row->entity_type])) {
      $classes = array(
        'computed_field_order',                // Standard class
        drupal_html_class($row->entity_type),  // and entity_type
        drupal_html_class($row->bundle),       // and bundle.
        );

      // It was serendipitous, but using the bundle name as a key prevents duplicates.
      // using Distinct in the query resulted in missed data.
      $items[$row->entity_type]['children'][$row->bundle] = array(
        'data' => l($info['bundles'][$row->bundle]['label'],
          "admin/config/content/computed_field_order/" . $row->entity_type . "/" . $row->bundle),
        'class' => $classes,
        );
    }
    else {
      $info = entity_get_info($row->entity_type);
      $items[$row->entity_type] = array(
        'data' => check_plain($info['label']),
        'children' => array(),
        );
    }
  }

Anyways, thankyou for your hardwork :)

ssoulless’s picture

ho that's weird, maybe I broke something in the last commit, let me check

ssoulless’s picture

Ok taking a look to the issue @pr.pushpinderrana when using custom content types it works normally, it does not work with native drupal content types =/ I will check whats going on, also the next commit will separate the admin for the configs in the drupal UI

ssoulless’s picture

ok @pr.pushpinderrana the problem is in the query just here


$query = db_select('field_config', 'fc');
  $query->innerJoin('field_config_instance', 'fci', 'fci.field_id = fc.id');
  $query->condition('fc.type', 'computed');
  $query->condition('fc.deleted', 0);
  $query->fields('fci', array('entity_type', 'bundle', 'data'))
    ->orderBy('fci.entity_type')
    ->orderBy('fci.bundle');
  $result = $query->execute();

it seems its not getting all the content types with its computed fields, can someone tell me what is wrong with the query?

ssoulless’s picture

Commited computed_field_order.admin.inc

Still looking forward for fix the problem with the query that gets all the content types with computed fields, if I cannot fix the issue Im going to show a list of all content types and let user choose the content type the user wants to change the computation order, if the content type does not have computed fields it will be empty otherwise the module will show the the computed fields, it is working right now if you type the path

admin/config/content/computed_field_order/[entitytype]/[entity bundle]

For Example:

admin/config/content/computed_field_order/node/article

Build a list of links with that menu structure will work

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.