What do you think about adding the ability to specify a default value for a column?

Basically, if a column value in a row is empty, it would display default text (i.e. "Empty"). I am willing to write the patch to update the views handlers, just wanted to get some thoughts on the idea first.

CommentFileSizeAuthor
#4 views-field-empty.patch1.75 KBdawehner

Comments

dawehner’s picture

there are definitve some use cases, but you have to write it different for each kind of string,
there could be empty, 0, etc.

this has to be implemented in views_handler_field.inc and be overwritten in other filters

merlinofchaos’s picture

I would be open to a patch that does this, as it is a common use case and right now can only be accomplished via theming.

dawehner’s picture

there is a patch but i cannot find the patch anymore :(
The patch added a option to every field

dawehner’s picture

StatusFileSize
new1.75 KB

i think i was wrong, i searched the issue queue, but couldn't find it.

here is a first patch, which alters the ->render function.

The problem with this is that, every ->render function has to be altered, there should be a better way to do it.

dawehner’s picture

Status: Active » Needs review

needs review...

dawehner’s picture

Version: 6.x-2.3 » 6.x-2.x-dev

move this to dev

dawehner’s picture

Status: Needs review » Needs work

move it to work, its horrible, there should be somehing in preprocess function if i understood/remember merlin correct

design.er’s picture

Subscribe. I've posted this issue: #401154: How to check if a view field is empty?
I'd like to help testing and hope we'll get a working version soon.

Regards,
Stefan

design.er’s picture

Any news?

phillipadsmith’s picture

Subscribing.

valderama’s picture

subscribing

deg’s picture

Subscribing

merlinofchaos’s picture

Status: Needs work » Fixed

Views 2.6 introduced a feature like this.

valderama’s picture

thx merlin!

it would help if you give a hint, where to find this feature. obviously some of us don't find it.

if i see it correctly, the style plugin inserts a zero for empty values? meaning that each style-plugin would need to define how empty values are handled? or am i completely wrong?

best regards,
walter

merlinofchaos’s picture

There's an option on every field for what to show if the field is empty, and a checkbox for whether or not to consider the numeric value of 0 as empty.

valderama’s picture

this was introduced in views 2.7 !! not in views 2.6.

therefor i could not find it.

merlinofchaos’s picture

D'oh! You are right about that. Sorry! Yes, in 2.7. I guess I can't read my own release notes. =)

Status: Fixed » Closed (fixed)

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