Just ran into this one.
Have a field.. specifically L_Type_ which appears in multiple classes RE_1, CI_2, MF_3, BL_4, FL_5 it's interpretation is set to lookup in all the classes, however, it uses a different lookup table for each class...
so for RE_1 it's lookup table is Type_1, CI_2 is Type_2, and so on
problem is when populating the fields table, the fields are looped through, added to an array checking each iteration if the 'SystemName' exists in the array already, if it does, just add to the classes array noting that this field is shared across classes. Which leads to the Lookup Table being set to the first appearance of the field's value and ignoring, if different, any other values.
Not sure how to go about handling this one, maybe switch lookup to contain a delimited list of lookup tables, then when you create a cck field you pull them out, explode them, and append each one to the allowed values list.
Gonna tinker around with this and see if i can figure out a clean solution.
Anyone else happen to have any fields shared across classes that have different lookup tables? or at least different lookup table names?
This system i'm dealing with at the moment is Paragon / Fnisrets.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | Screen shot 2010-09-20 at 11.18.09 AM.png | 31.85 KB | jday |
| #11 | drealty-6.x-1.0-beta5.zip | 47.77 KB | camidoo |
Comments
Comment #1
camidoo commentedoh, how i ended up discovering this is was trying to display the field and it was showing the value instead of the lookup, i.e. ( 38 instead of Single Family ), as i started to investigate i looked in the allowed values for that particular field and discovered that 38 wasn't in the allowed values list. And after some research discovered what i posted above.
Comment #2
Garrett Albright commentedI ran into this once in the early days of PIRETS 3, but wrote it off as just a fluke of an individual funky RETS provider. I'm quite disheartened to see that's not the case.
The problem with just appending the values to the allowed values of the CCK field is that we'll have several computer-friendly values for the same human-readable value. For example, if the field represents roofing style, there will be a "Shingle" for RE_1, a "Shingle" for CI_2, etc, each with different computer-friendly values. If all we care about is displaying listings, this isn't a problem, but things get ugly quickly when it comes to searching listings. If we have a drop-down menu field which shows all possible values for that field, "Shingle" (and other values) will be listed several times. And if we try to search for RE_1 listings with the "Shingle" value for CI_2 listings, zero listings will be returned…
(takes off glasses, closes eyes, rubs bridge of nose between fingers, exhales deeply)
Comment #3
camidoo commentedyea, i see what you mean, not really sure how to go about solving this one, gonna give it some thought and try out a few things. I'll post back any ideas/success/failures.
Comment #4
Garrett Albright commentedWell, I thought up a solution which might be feasible. We add another table (sigh) named something like pirets_lookups_by_class which contains these fields: system_name, class, lookup, lookup_multi. The latter two fields are removed from the pirets_fields table.
Instead of storing possible values as "computer_val|Human friendly value," CCK fields will just store the human friendly values. So that way "Shingle" can have the same value across all classes. This seems destructive to the data from RETS - how do we get the computer value if we're just storing the human friendly value? Well, we just have to use some idiotic query like:
SELECT pl.value FROM pirets_lookups pl INNER JOIN pirets_lookups_by_class plbc ON pl.lid = plbc.lookup WHERE pl.long_value = 'Shingle' AND plbc.class = 'RE_1'Thinking of writing the hook_update_N() for this is making me lose bladder control. And this all falls apart if the Roofing lookup for RE_1 has "Shingle" and the one for CI_2 has "Shingles" and the one for MF_3 has "Shingel" and the one for BL_4 has "shingle."
Comment #5
camidoo commentedQuestion, are you counting on the allowed value list to populate exposed filters? Exposed filters in views that is.
Comment #6
Garrett Albright commentedIf we want to use a select list/menu for the exposed filter in question, is there another way to do it? I suppose I could define my own CCK field and/or Views filter, but that's not really what PIRETS is about. Maybe I don't understand your question…
Comment #7
camidoo commentedWell, what i was thinking is, to skip the allowed values all together, just store the 'data' portion of the field, use a custom formatter that basically does the lookup and then can use the context of the node to decide which lookup table to use, based on class.
Problem is, that in doing that you don't have any allowed values for exposed filters. Which is what views uses to populate the drop downs. content_allowed_values(). I was tinkering around with using some php to populate the allowed values list, but haven't really found an elegant solution.
I also kicked around the idea of a new cck_field type, or basically just extending the text field type. But that doesn't really solve anything as the allowed values are really the issue. Meaning there are use cases where the 'key' portion of the allowed_values could be a duplicate, which puts us right back in the same boat.
I've got a formatter working, is pretty simple to implement, and the only real change that you do is that in the lookup field you serialize an array of key value pairs, keys being the class system_name, and value being the lookup name.
In the formatter you get the field_name, grab the lookup setting, get the node from the $element, and do everything you need to do.
Comment #8
camidoo commentedOh, also worth mentioning is that this is/can be a field by field or case by case, 'fix', meaning that if that formatter isn't selected for that field, everything is handled normally, with allowed values.... just would have to change how you pull the lookup table name a bit to account for now storing it as an array.
Comment #9
Garrett Albright commentedDid some initial work on this. I'm probably going to just give up on coming up with an elegant upgrade path for this and instead just tell everyone to update their fields and listings manually…
Comment #10
Garrett Albright commentedI spent a whole lot of time on this yesterday, but eventually I stopped because I really did not like the mess the code was turning in to. It was a learning experience, though. I ended up committing what I had so far, then reverting back to the pre-mess changeset.
I definitely plan on taking another swing at this eventually, particularly now that I have a clearer idea of the magnitude of the problem. However, I'm starting to think that, like #726392: Multiple Server settings and connections and Resource Type, this is an issue which is going to have to be tackled through a major rewrite of PIRETS' connection code rather than tweaking what's there now.
Comment #11
camidoo commentedi eventually came up with a solution. Basically what i did was switched from using value|long_value to using long_value|long_value, additionally i switched from using lookup_name as a single item, to serializing it as an array of lookup_tables keyed like "class" => "lookup_table_name".
the big shift was to go from requesting RETS data as COMPACT to COMPACT-DECODED, this forces the rets server to send the lookup values as decoded values rather than sending them as they're 'value' counter parts. So, for instance, L_Type comes back as LongValue,LongValue,LongValue, instead of value,value,value. (single-family,commercial,building vs. 17,19,23) or whatever.
then what i do when i create the cck field is i loop through all the look up values in the each table from the lookup_name array, and array_merge() them together. Where provided that the keys are strings, which they are, duplicates will be merged together, resulting in no dupes in drops downs or whatever.
you can dig through my code and see how i handled it if you like, so far it's working fine, i've attached it at the bottom. I'm currently waiting on cvs access, seems like it takes awhile.
Comment #12
jday commentedso what can I do when fields are showing the values (41) rather than the lookup long-values (finished)? just noticed after moving to yet another server...
Comment #13
Garrett Albright commentedNothing, at the moment. However, it appears that a client may be fronting the money for us to put int he time to get this working, though I'm not entirely sure how yet - whether it can be done in PIRETS 3 without too much trouble, or if we're essentially talking about building PIRETS 4 here. We should have a clearer picture of things come the weekend.
Comment #14
jday commentedlooking into the database, the cck fields are populated with all lookup ids in one row (i.e. 3739404217)
if I go and edit the property it will split those values into separate rows, see attachment
so seems like the updates are missing a for each loop or something...?
Comment #15
Garrett Albright commentedGrr… I bet that's due to a conflict between code to remove commas from certain fields (due to Interealty sticking commas in fields where they don't belong) and multiple-value lookup fields, which will legitimately have commas in the field to separate values. Dumb mistake, but also surprised nobody's caught it before…
When the next dev release becomes available, please give that a try; flushing and refetching the affected listings.
Comment #16
jday commentedThanks Garrett, Sept.21 dev got my multi-value lookups displaying properly again. Looking forward to Pirets 4 : )
Comment #17
webavant commentedThis is still an issue for me with FlexMLS using the latest PIRETS dev release (Dec 30 2010). It appears the PIRETS is only getting the allowed values for the first property class. I created a duplicate issue here, please feel free to close it, (sorry about that).
Comment #18
webavant commentedAnd to answer your question, yes, I do! FlexMLS does this too, and it's still an issue with the current PIRETS dev release. The lookup values are showing for every class besides the first one (A/Residential).
Comment #19
webavant commentedAlso worth noting that this solves nothing currently with PIRETS. I tried adding ?Format=COMPACT-DECODED to my Search URL. It results in the multiple select field blanking issue, which occurs when editing a PIRETS node and saving it. Since PIRETS populates the "allowed values" for the CCK multi-select field, and since PIRETS inserts the COMPACT-DECODED value (which is not an allowed value), it is blanked when the node is saved manually a second time. Any ideas how to workaround this? It seems like I need to add a loop for whichever function is determining all possible values, and force it to fetch values for each class before populating the content type allowed values.
Comment #20
webavant commentedHmm, so it looks like you're already doing that in pirets.connect.inc, but for whatever reason, it only gets the data for residential class on FlexMLS.
Comment #21
webavant commentedSo I printed the contents of $rets_fields[$field['SystemName']] during the loop in pirets_fields_fetch() from pirets.batch.inc. Shouldn't the 'classes' array contain all of the classes and not just one? See below:
Comment #22
webavant commentedI am interested in seeing a resolution to this issue. Does that entail rewriting PIRETS as you previously suggested? I don't know what your interest level in it is, but if you created a project on an "all-or-nothing" style funding platform, I would definitely pledge a portion to help foot the bill.
Comment #23
Garrett Albright commentedThe truth is I haven't worked with PIRETS in a while, but taking a glance at the commit history, it appears that what happened is that the code I wrote to support this was in a specialized branch for a particular client. I thought I had merged it into the mainline branch, but it appears I didn't. Anyway, if you're adventurous, you can access this code in the BitBucket repository - it's the 3.1 branch, which is a little confusingly-named.
The other truth is that I no longer work for PI full-time anymore, instead more as a consultant/freelancer when they need something done that only I would know best (like PIRETS). And I'm really not in love with RETS enough to work on PIRETS in my free time… So, yeah, it may help to contact PI and get a contract. Then PI can come to me with a little financial incentive to get it done (or possibly one of their in-house programmers, though I'm not sure how well they know PIRETS yet).