If the view is empty, shouldn't the view still be rendered and let the view settings handle the display ?

I'd like to be able to have the view empty text settings be displayed if there are no nodes to show in the view, but the way the code is now, if there are no nodes in the node reference field, then the view isn't rendered at all.

I tried modifying the code to pass in an empty argument array to the view preview instead of just returning null, but that didn't seem to work for some reason.

I don't know the views API well enough to provide a patch... if you could provide me with pointers as to how best to do this, i can have a go at providing a patch.

Comments

joachim’s picture

Status: Active » Closed (works as designed)

> If the view is empty, shouldn't the view still be rendered and let the view settings handle the display ?

Not really -- with other CCK formatters, you simply get nothing displayed if the field is empty.

You could hack this bit:

  // We get here even if the field is empty, so check that the 0 value is not a proper nid
  // and return nothing so the label is not shown.
  if (!$element[0]['#item']['nid']) {
    return;
  }

but it's really going against the grain of CCK, so it's not something I would include in the module.

dayre’s picture

Ok... that makes sense. Perhaps it could be an option for this formatter type ? I'll look into it and let you know.

dayre’s picture

ok... i give up. Thought it would be nice if there were an option in the formatter settings in the node type for that field to add some "display view even if empty" option... but cck doesn't have any hooks or settings for formatters that can integrated into the CCK admin.

So, i'll just do something goofy in the view template.

joachim’s picture

Yeah, there's nothing to give options for formatters.
Though I see date fields have a secnd dropdown in the display options. No idea how date module manages that, though it's probably per-field type.