I'm rewriting a field output as shown in the attachment. I'm outputting the field as a link using a replacement pattern.

If the field is empty, it is still rewritten and the url is the base domain.

I would like for the field output to be empty if the field is empty.

Perhaps my configuration of the field output is wrong?

Thanks

CommentFileSizeAuthor
link.jpg115.5 KBawolfey

Comments

mark trapp’s picture

Category: support » bug

Having the exact same problem. Field is set to output as a link using a replacement pattern: I expect it to not print anything if the field is empty, but instead it rewrites the field to include the link in all cases. A workaround is to hardcode the replacement in the template files, but that's less than ideal.

michellezeedru’s picture

Subscribing to this issue... having the same problem and looking for a solution. Thanks to anyone who can help with this!

seattlehimay’s picture

Subscribing. I'm having the same problem, and haven't found a clean solution.

son of nun’s picture

I am also looking for a solution. Any help or trick would be welcome.

awolfey’s picture

My solution was to use a custom views field template. That solved it for me. I have not checked since then to see if the problem is fixed.

BenGman’s picture

Subscribing

merlinofchaos’s picture

Category: bug » feature

This isn't really a bug, it's a feature request. One I intend to work on (maybe someone would like to write a patch?) to provide special handling for empty fields.

merlinofchaos’s picture

Status: Active » Fixed

Checked in a new system to allow this to happen.

awolfey’s picture

Excellent! Thank you. I needed this again just today.

Status: Fixed » Closed (fixed)

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

michellezeedru’s picture

Sorry to comment on a closed issue, but I am using Views 2.6, and don't see the system for handling empty fields. I'm not exactly sure what "checked in a new system to allow this to happen" means. Has this feature has been added? Am I missing this functionality somewhere (looking in the configure field settings)? Is this in dev only? Please advise.

If this has been added and I'm just not seeing it, thanks for adding this feature!

Kakulash’s picture

It's in the latest dev version.

Thanks for adding this! Wish I had seen this post before I had made my own. Going back to take care of that one...

marcoka’s picture

If the data of a string supplying field is empty and used to generate a link, the link is generated.
For example: You post pictures that have an filefield(required) and an additional textfield(not required, [field_link_value]).
If you select the filefield under FIELDS in views you can say, "output this field as link" and chose [field_link_value]. If [field_link_value] is empty a link is still wrapped/generated around the image (a href="/sitename/%20").

gomes.mr’s picture

Assigned: Unassigned » gomes.mr
Status: Closed (fixed) » Active

Hi,

i have the same problem related above. May I insert a if condition in a rewrite output field?

thanks

mark trapp’s picture

Assigned: gomes.mr » Unassigned
Status: Active » Closed (fixed)

Reopen a new issue: this was fixed a long time ago.

Anonymous’s picture

Hi
Perhaps following description may help you out. You can use custome filed as PHP and you can write your desired code in php, the value would get displayed.