This module is a good alternative to panels-based nodes, and really helped on a project.

I find it to be much easier to use if you can get a small preview of the field contents when selecting and sorting the elements into zones.

The attached patch modifies _composite_references_preprocess to pass the $node object so that field previews can be rendered.

It also removes the empty parent field in instances where multi-value fields are used.

CommentFileSizeAuthor
composite.patch6.45 KBagentrickard

Comments

bengtan’s picture

Assigned: Unassigned » bengtan

Hi,

Thanks for this patch. You're right, it does make things easier.

However, I'm considering making a minor change or two to the patch before committing. Among other things, _composite_cck_preview_element() might go into composite.module since it's not really CCK specific.

I will try to spend some time on this in early January. Let me get back to you on it, but if I seem to be taking too long, feel free to bump this issue.

Thank you.

agentrickard’s picture

Not a problem.

agentrickard’s picture

The patch does not work correctly with Filefield, since the UID handling falsely returns the UID. So this patch needs some more love. I added an FID if check handler to _composite_cck_preview_element as a temporary fix.

agentrickard’s picture

Status: Needs review » Needs work
bengtan’s picture

Hi,

I'm looking at this issue now, and merged your patch into my own private repository (which I will later propagate to drupal CVS).

But ... I modified your patch slightly in the process (no functional changes, just some syntax transformations).

Do you want to communicate to me the changes you did for comment #3?

Either a new patch (from your system), or a code description will do. I can do the necessary merging and then commit to drupal CVS.

agentrickard’s picture

I just added an 'fid' IF statement between the NID and UID checks in _composite_cck_preview_element().

  // File reference
  else if (isset($element['fid'])) {
    return l($element['filename'], $element['filepath']);
  }
bengtan’s picture

Status: Needs work » Fixed

Composite Layout 6.x-1.0beta6 has been released with your proposed functionality. Please use and let me know how things go. Thank you for your input.

agentrickard’s picture

Status: Fixed » Needs review

Nice. I found one small bug that occurs if we have an empty multivalue field.

Fix is line 85:

  // Get a list of individual field values for multi valued fields or single fields
  foreach ($fields as $field => $field_info) {
    $item = $node->$field;
    if ($field_info['multiple'] && !empty($item)) {
...

Adding the !empty($item) prevents the foreach from running when there are no values.

bengtan’s picture

Hi,

I hope you didn't mind me mangling your patch before committing. Maybe didn't quite conform to Drupal collaboration conventions, but anyway ...

I'll take your word for it that comment #8 is a fix, and will commit to CVS sometime soon.

bengtan’s picture

Version: 6.x-1.0-beta5 » 6.x-1.0-beta6
Status: Needs review » Fixed

The change from comment 8 has been committed to CVS and will be incorporated into the next release of Composite Layout, whenever that is. Thank you.

agentrickard’s picture

Works for me. You have to be comfortable with the code you commit.

Status: Fixed » Closed (fixed)

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