In the 2010-Oct-13 release of 6.x-3.x-dev, if you use the "Rewrite the output of this field" option and put in some text and also tell the field to "hide if empty", the text will still display. This worked properly in the 2010-10-11 release.
For example, I'm creating a list of actors and characters and each entry can have up to 5 actors/characters. I'm rewriting the output of the various Actor and Character field output so that for the fields Actor2 through Actor5 all have a " | " in front of the field replacement pattern, and there are parentheses surrounding all Character field output. This way all the fields would have the proper "formatting" when output regardless of how many actor/character entries there are per record. With this release, it creating output like this (if there are fields hidden if empty):
Actor1 (Character1) | () | () | () | ()
whereas prior releases would only display:
Actor1 (Character1)
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 941114-proposed-fix.patch | 787 bytes | dawehner |
| #12 | 941114-proposed-fix.patch.txt | 835 bytes | HunterElliott |
Comments
Comment #1
HunterElliott commentedAs an FYI, this issue still exists in version 6.x-3.x-dev dated 2010-10-15.
Comment #2
HunterElliott commentedTo verify I had the right version when it last worked properly, I reloaded the 6.x-3.x-dev version that I said was released on 2010-10-11 and I was incorrect. It was released on 2010-09-30. Re-installing this previous version did restore the "hide if empty" routine to work properly.
Comment #3
HunterElliott commentedIs anyone able to determine whether or not this issue will be addressed in a future release?
Comment #4
dawehnercan you try out git bisect to find the patch which caused this issue?
Comment #5
dawehnerSee http://www.kernel.org/pub/software/scm/git/docs/git-bisect.html
Comment #6
HunterElliott commentedSure. I've not used that before but I do have both a good and bad version of the 6.3.dev modules. Let me see what I can find.
Comment #7
HunterElliott commentedDereine, I must admit to being a git about GIT. I wasn't able to figure it out. However, I was using another app to compare differences between files and wonder if any of the following could be part of the issue:
in handlers\views_handler_area_text.inc, line 20 has the following in the "good" version"
'#description' => $description,whereas in the "bad" version it is not present.
Line 52 of the good file reads:
if (!$formats[$format]) {whereas the corresponding line in the "bad" version (line 51) reads:
if (!isset($formats[$format])) {-------------------------
in handlers\views_handler_field.inc in the "good" version starting at line 517 it reads:
whereas the "bad version seems to have some of the items "flipped" in terms of sequence.
The "bad" version of this file starting on line 517 reads:
Could the "flip/flop" of the IF statements be the issue?
Comment #8
zualas commented@HunterElliott
Looks like you found the issue source. I flipped the two conditions back, and I don't have the issue anymore. Thanks!
Comment #9
HunterElliott commented@zualas: Great to hear that a) I wasn't the only one with the problem, and 2) that I found the right code :)
Here's to hoping one of the maintainers actually sees this and can incorporate the fix!
Comment #10
esmerel commented@hunterelliott - I'm going to go ahead and assign this to dereine, but if you feel up to actually creating the patch yourself, I'm pretty sure he wouldn't mind a bit :)
Comment #11
HunterElliott commentedI'll work on getting a patch made asap. I'll grab the latest version of the module to compare and make sure it's not already been addressed.
Comment #12
HunterElliott commentedAttached is my first ever attempt at a patch. I hope it's in the proper format, etc. Here are the contents of the patch file:
Comment #13
HunterElliott commentedSo... did I create the patch properly?
Comment #14
bojanz commentedThe patch should be created from the views module root, not the drupal root (only core patches are created from drupal root).
Not sure about the fix though.
The change you are reverting was introduced in #936828: [token] empty text replacement does not work with values of zero that are formatted, so we need to satisfy both use cases here...
Comment #15
bojanz commentedComment #16
dawehnerHere is a fast rerole.
Comment #17
dawehnerIn general it looks fine for me.
Comment #18
bojanz commentedWhat about my #14? (xjm's patch mentioned...)
Comment #19
dawehnerOh
Comment #20
dawehnerThis might should be configurable, right?
Comment #21
gopherspidey commentedBy the way this also affects the 7.x-3.0-alpha1. I was trying the rewrite the contents of the field with to display an img, but I only wanted the image to show up if the field was set. This was to let end users know that there was something there. I ended up creating a customer formatter in drupal 7 to get around this issue of rewriting the field output.
Comment #22
jindustry commentedI tried this patch and experienced strange behavior. Before the patch, I can rewrite a field but it's not hidden if empty. After the patch, it's hidden if empty but it doesn't get rewritten. Is anyone else getting this behavior? My view includes multiple node types, and some nodes do not contain the field at all.
Comment #23
rp7 commentedsubscribing. rewriting field output -> empty field doesn't hide.
Comment #24
rootdownmedia commented+1 subscribe. Any workarounds in the meantime?
Comment #25
mcornes commentedWell spotted. This is still a problem in the latest v6 Views latest Dev I downloaded today dated the 21 Jan 2011. I manually added the patch into the mix and boom my "hide if empty"s began working, even when I was rewriting the field!
Thanks.
Can be seen working here, the results column needed hiding if empty, because the game hadn't been played yet, and rewriting if a score was there so I could link to the match report.
http://www.loreto.ac.uk/sportingfixtures
Comment #26
karljohann commentedThis is still a problem in the Feb 5th dev release.
Comment #27
hatsch commentedi have the same problem. applying the patch from #16 helps, the field is not showing anymore if empty
although the "Empty Text" Field is not working yet.
Comment #28
xjmHm, tracking.
Comment #29
xjmRe: #20, it does seem to me that it would need to be configurable... that, or do we need to evaluate zero values as a special case?
Comment #30
HunterElliott commentedDigging around in other issues regarding this same problem, I found a work around. I think it's a bit of a kludge as this feature should work as it did prior to the updates from October 2010 (IMO).
This "fix" is not intuitive (well, at least not to me). When you've gone in to the Rewriting section, click the "rewrite the output of this field" and put in your token like you always have. This is where it was not intuitive to me. Click the box next to "Output this field as a link" in the rewriting section. (Why would I click this when the option to output it as a link is towards the bottom of all the options?) Ignore all the other options here and just put something in the Prefix and Suffix sections. For me, it would be things like ( and ) or |. Then just do your regular "hide if empty" stuff.
Comment #31
laroccadahouse commentedcode in #12 worked for me re: rewriting field output -> hide empty field.
Comment #32
riyasmtpm commentedhi Tim all
Somebody help me with my requirement pls...I want to allow my users to choose their front page and save the selection with their profile.Next time they log in they have to see only the terms which they are selected before.
Exmple: My site(job portal) having 3 vocabularies
1.City
--New delhi
--Banglore
2.Experience
--1 year
--2year
3.Technology
--PHP
--Java
Here i need logged in users to choose the terms
for example a person from Banglore with one year experience in PHP Will have to choose these terms in his front page.
Pls help as soon as possible and advance thanks for your precious time.
Comment #33
vikramy commentedSubscribing
Comment #34
johnpitcairn commentedAck. Subscribe.
Comment #35
fletch11 commented... me too
Comment #36
jonathanmd commentedsubscribing
Comment #37
adooo commentedsubscribing
Comment #38
dawehnerThis is a duplicate of #1020540: Add a "Hide Rewriting if field is empty" option On this issue is already a patch.
Comment #39
dawehnerThat's the wrong status.