Jump to:
| Project: | dRealty IDX |
| Version: | 7.x-3.0-beta3 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | camidoo |
| Status: | active |
Issue Summary
I've been kicking this around in my head the last week or so. Currently I have this implemented with hook_entity_presave and some Fields, but I thought this was a good candidate for an entity property, not a Field.
I'd like to add some settings for dRealty that lets an admin add in the office firm IDs that belong to them. Then, while a property is being processed, if the office ID is matched, then the entity property is set to 1. Lets call it office_listing for example.
<?php
// during batch import/updating
if (in_array($field_value_with_office_id, variable_get('drealty_office_ids', array()))) {
$drealty_listing->office_listing = 1;
}
?>I do this with a boolean Field flag but it seems better suited for a entity property. The only reason I do it is basically so I can sort an offices listings first before any other listings, so when a user is on the site they see that firms listings first in any search result, then anything else. Preferential sorting is requested by just about every realtor/firm we've worked with over the years. I don't know any other way to sort based on this condition, if this is already implemented?
Thoughts? If it makes sense I can start working on a patch unless there is a better way to accomplish this.
Comments
#1
I had to handle this in a custom module with entity_presave, or whatever the function is. Ideally, we would be able to check-off/autocomplete several offices and/or agents to flag as "featured", or something of the sort. I having Entity Reference support might change how that work work.
#2
Well the Referencing of offices would be one thing, this is mainly for identifying/sorting listings. The one brokerage I am working with has 4 locations (4 IDs). If you are using Views to display listings, when you display all of them, I don't know of a good way to show all the brokerage listings first before the rest, in the same view.
I have a generic search that lets you type in some data, and it goes to a results page, where I show the listings for that brokerage first and then everyone else. Visually, you can't tell, it just shows results. But in the view, I am sorting by that field value DESC, so all with 1, then 0.
#3
Right, I'm doing the same thing with a single agent's listings. Actually, I misspoke earlier about using entity_presave, although I could have gone that route also. I added a Computed Field to the drealty_listing entity type, with the following code:
<?phpif (array_pop(array_pop(field_get_items($entity_type, $entity, 'field_agent_id'))) == '824723201') {
$entity_field[0]['value'] = "1";
} else {
$entity_field[0]['value'] = "0";
}
?>
Although, I do wish there was a way to do it without hardcoding those IDs. Perhaps it might be cool to tie it into user profiles, also. More possibilities for multiple agents/agencies.
#4
Is there a reason you can't get the same behavior with a hard-coded filter on a view, using the office ID or the agent ID? Or with an contextual filter on a view? That would keep you from having to store this data, which seems like the equivalent of setting 1+1=2 in the database. It does make searching seem easier, but it just seems like the same can already be done using Views?
Just a thought...
#5
What if the brokerage you are working with has multiple codes? Mine has 4. Also, can Views sort asc/desc with a string? Or am I missing something?
#6
You can create a filter group in Views using the Office/Brokerage ID, and then put your four IDs in there with OR queries... That should provide what you need. Also, yes, views can sort asc/desc on a string...
#7
I'm not quite sure I understand. If you have 300 Office IDs (strings) how do you sort by 4 first, then anyone else?
#8
Ah, I see that you're doing. Yes, that is a hole in the theory. I was thinking along the lines of showing only listings for the site owner via a filter (View Our Listings), not sorting so that the site owner's listings appear at the top of a listing page. Our MLS disallows that type of sorting as part of their regs, so I didn't think of the option. In that case, what you're talking about would seem to be the only solution, aside from using a views query alter to sort some kind of boolean condition as a subquery in the sort on the view, which would basically be generating your flag on the fly instead of via preprocessing it as you're doing now.
#9
Kevin, when are you guys bringing back the office and agent entities? We should have a "featured" boolean field that can optionally presave as 'true' when agent ID or name matches a list of values selected during the listing entity field setup.
#10
I think the idea was to gut that stuff for 3.x and solidify the listing and import class(es) and entities, so that the others could work much smoother. I would think in another release or two we should be at a good point to that.
I also think that the average of brokerages actively using the Office/Agent portions of their vendors IDX system was somewhat low- meaning the data was stale, old, or not existent (like agent information). Even if we had the Agent class still, for example, half of the Agent IDX codes are missing because agents are not keeping that data up to date.
We will get back to it at some point.
#11
the office portion is now implemented! and agents coming soon, i think this is a great idea and shouldn't be too hard to implement something like this, i think i'll get to it this weekend.
#12
I plan on adding this on as a drealty_listing entity property (bool) and making the proper adjustments in the import process. This will require a new settings page that lets a user enter their brokerage codes- though this also requires a lookup against the Office class as well.