Hi Team,

I am using Views and Drealty. My listings have districts. I'd like to create an exposed filter with a drop down menu that lists the districts.

This is what I tried: First I created a new Vocabulary called Districts, and added terms for each of my listing districts. Then, I selected my Drealty Listing Type ->Manage Fields. I added a District field, selected the Term Reference widget type, and mapped the RETS district field to my District field. I then flushed and imported data, and checked my view, but the district field does not display any data. It works as a drop-down menu, but any option filters out all listings.

I checked the RETS district field and their is data on the server. It is of (type, length); (Character, 5) according to RetsMD.

It would be nice if the RETS data could be imported and translated into a term reference.

If this doesn't happen, I recognize the following work around: create a view for each district. Create a drop down menu, where each item points to different view. Or, alternatively, make the end users type the district abbreviation into the exposed filter, and offer help.

Best regards,

Comments

j9’s picture

I am with you on this completely, mgriebe.

Excellent feature request that would allow a lot better Views faceting in place of a search.

camidoo’s picture

drealty does not operate on taxonomy fields. In order to populate taxonomy fields you will have to do that in a custom module via

HOOK_drealty_import_presave_alter(&$entity, $context)

Where $entity is the Listing that is about to be saved, and $context is any array of context information relevant to the listing:


$context['field_mappings'];   //is an array of field mappings
$context['connection']; //is the dRealtyConnection object
$context['resource']; //is the drealtyRetsResource object
$context['key_field']; //is the RETS systemname of the key field from the RETS system
$context['rets_item'];  //is an array of values keyed by systemname imported from the RETS server

There is not an easy way to accommodate Taxonomy mapping into drealty, and i doubt very seriously that feature would / will make it into the feature set unless someone can come up with a system to do it.

stockliasteroid’s picture

I did this exact thing with Rules:

Create a taxonomy vocab called "Listing Areas".
Add a "Text List" field to it called "MLS Areas", set it to display as checkboxes (multiple values).
Set the possible values of this field to be all of the possible areas in the MLS, which you can get using RetsMD.
Add a term reference field to the listing entity, and set it's vocabulary to "Listing Areas".
Create terms in this vocabulary, associating each term with the MLS listing areas it represents, via the checkboxes added prior. Using this method a term can represent multiple areas, so you can make "meta-areas" for your visitors to use since they won't need the granularity the MLS provides.

Create a new rule that runs after a listing is saved. This rule should:
Have a Fetch Entity By Property action, and use this to find the taxonomy term associated with the area for this listing.
Have a "Set a data value" action, and use this to set the taxonomy term on the listing using the previously loaded Term entity.

Voila! Using taxonomy with rules like this you can arrange your terms into hierarchies, use Search API to facet on them, all without writing code, and all featureable via ctools. The only downside is that you have to set this up in advance and then import all your listings, and if you change your area mapping you must do a complete re-import. But that's a small price to pay, I think :).

j9’s picture

Hey super!

I am going to give this a try and report back. Thanks!

mgriebe’s picture

Hi Stockliasteroid!

Thanks for this! could you please explain a little more how to create the rules? I am not sure what the drill-downs mean, and what property I should be using to fetch.

mgriebe’s picture

Ok, let me explain my trip-up more carefully. My rule is:

=================================
{ "rules_map_multi_features_2_to_listing_features" : {
"LABEL" : "Map Multi-Features-2 to Listing Features",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"REQUIRES" : [ "rules", "drealty" ],
"ON" : [ "drealty_listing_insert" ],
"IF" : [
{ "entity_has_field" : { "entity" : [ "drealty-listing" ], "field" : "field_multi_features_2" } }
],
"DO" : [
{ "entity_query" : {
"USING" : {
"type" : "taxonomy_term",
"property" : "field_mls_features",
"value" : [ "drealty-listing:field-multi-features-2:0" ],
"limit" : [ "" ]
},
"PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
}
},
{ "data_set" : { "data" : [ "entity-fetched" ], "value" : [ "entity-fetched" ] } }
]
}
}
================================

The context: I created a taxonomy with machine name features_list. In it I added a text(list) field called mls_features. I added the allowed features. Then, I added the Taxonomy terms to the taxonomy features_list and ticked the associated boxes.

Next, under drealty proprety type>manage fields, I created a new term reference field, field-multi-features-2. I associate the features list taxonomy with the term reference field i just created.

Then, I wander about the rules dialogue until I come up with the above. During rets-import, I get the warning or error "undefined index: tid taxonomy.module:1781." And, no data gets saved.

I think I messed up the rule.

1) Can I see your rule?

2) Can you fix my rule?

3) Can you walk me through the rule creation process?

4) In your rule, if you trigger the action on update drealty listing, will that sidestep the need to flush and re-import all?

5) In your example, you have list areas, and a property is in one list area. Will your rule work for a list of features, where a single mls entry has multiple comma-delimited features? What if we changed the widget from check boxes to tagging?

mgriebe’s picture

Below explains one way to create a filter in views for field that has potentially multiple descriptors per listing. For instance, suppose your RETS server has a field called "Features" and each listing can have many Features listed "Deck, Pool, Woodstove", and you want to create a view that allows users to select multiple features that a property must have, then the following is for you.

1) Install Rules Autotag. (this may be unnecessary in general, but it worked for me.)

2) Create a taxonomy and add text(list) field to it.
Add the allowed values to the text(list). Allow unlimited selection if necessary.
Add terms to the vocabulary, associating allowed values with it (via tick boxes).

3) Add two fields to the drealty property type.
One is of text or long text format, and it captures the comma-delineated list of features -associate it with the relevant RETS field.
One is of type Term Reference. Do not associate it with a RETS field and exclude it from the hash. Select the Vocabulary you created above. Make sure Number of Values is set to unlimited, otherwise you cannot assign it to receive tags.

4) Create the rule that extracts from the drealty text field with the RETS comma-delineated list of features and puts those terms into the drealty Term Referecnce field.
a)add event: save drealty
b)Add condition - Entity has field
Entity - Data selector: drealty
Field - Value: Text field with RETS list
Add condition -Entity has field
Field - Value: Term reference field
(by adding conditions, it enables drill down when using the Data selector.)

c)Add action set: Autotag to terms list (very bottom)
The text for extracting terms - Data selector: drealty text field
The vocabulary used for extraction - Choose from the select list
Target list for storing extracted terms - Data selector: drealty term reference field.

From there, go to views and use the Term Reference filters. I use Better Exposed Filters.
**Note: If each listing has one and only one descriptor, like Zip Code, or Property Type, then you can just create a Text(list) field for your drealty listing type and use it in views.
**Also: there is probably way using presave_hook to alter a comma-delineated list of things into a new-line list. Then you could change the list into something drupal text(list) can work with. But, I can't handle that yet.

j9’s picture

Thanks for posting this info mgriebe!! :D

camidoo’s picture

Status: Active » Closed (works as designed)
camidoo’s picture

Issue summary: View changes

Changed a word to be more clear.