In many views, below the Node body, I also show Comments (presumably, the latest comment).
I have the view set for Comment: Body to Hide if empty.
But for all nodes that do not have a comment, the view shows "n/a" instead of nothing (empty). So where the comment would show on the web page, "n/a" appears instead.
When the node has a comment, its body shows as desired. The behavior is entirely tied to lack of an actual comment.
I've diddled with all the view settings related to Comment: Body but nothing gets rid of the "n/a". Hours of experimenting but it never goes away when the node has NO comment.
If I put something into the Comment: Body Empty Text field, it never shows, suggesting "n/a" is being inserted before the field gets evaluated as empty or not.
I've searched and searched in modules, code, theme, etc but can't find where "n/a" originates, but it happens for EVERY node that does not have an actual Comment. It's quite ugly and not readily hidden by CSS since it is actual text, just inappropriate text.
Anyone seen this? Any clues?
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | views-field-markup.patch | 625 bytes | dawehner |
Comments
Comment #1
dawehnerThats how check_markup works.
You could solve this for example with theming of the comment: body field.
Comment #2
merlinofchaos commentedUgh. WE should fix this so we don't check_markup on empty fields, because that n/a is ridiculous.
Comment #3
hawkdrupal commentedAfter posting here I searched several Drupal discussions and there are many complaints about "n/a" marring what would otherwise be perfect pages. It's really goofy that this internal result message is forced all the way through to the end user.
In Views, this behavior destroys the use of Hide if empty because the field is never empty.
So, one solution in Views is to not check_markup of an empty field, because that is what triggers "n/a" to be returned?.
Or maybe easier/faster to implement in Views is to check for a result of "n/a" and treat that as empty, just as 0 can be treated as empty?
Should be a simple hack but I don't know where to do it.
Comment #4
dawehnerHere is a easy patch
Comment #5
hawkdrupal commentedThe patch fixes the problem -- thank you!
For others who use the fix, one side-consequence to note:
The patch treats a Comment that would otherwise show as "n/a" as empty so it does not output anything, including the CSS class views-field-subject. Therefore, any spacing or other formatting that was implemented via this class will not happen when there is no comment for a particular node.
I was using this class in a view to force a space at the bottom of the node before the next node. I can move this to the top of the node rather than the bottom, but that has consequences too. The only way I see to control the overall positioning of each node in a view is to diddle with the class of the first and/or last field of the node.
It would be wonderful to have a view node-level class -- one consistent class that wraps each node in a view, whatever it might contain, useful for inter-node spacing, possibly a background color, etc.
Comment #6
sittard commentedSubscribing +1
Comment #7
merlinofchaos commented#5: Use the 'empty text' on the field to output or something so that you will still get an empty div?
Apploed to 2.x and 3.x for D6; does not apply to D7, marking for D7 port.
Comment #8
dawehnerhttp://drupal.org/cvs?commit=290912