Add a fax number for each location
bomarmonk - July 25, 2007 - 20:17
| Project: | Location |
| Version: | 5.x-1.x-dev |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | bomarmonk |
| Status: | closed |
Description
Here is a duplicate of the phone module, only this one if for fax numbers. I simply searched and replaced "phone" and "Phone" with "fax" and "Fax." I also adjusted the weights so that the fax number shows under the phone number.
| Attachment | Size |
|---|---|
| location_fax.tar_.gz | 7 KB |

#1
Any chance of getting this and the phone version alluded to for 5.x? Would be really nice to have the field in with the address instead of adding phone numbers separately.
Thanks,
Michelle
#2
#3
Okay, here are both the phone and fax modules with .info files for Drupal 5. Unfortunately, I'm not a PHP coder, so these need some work. but for now they are displaying my existing phone and fax numbers in the nodes and node forms... but again, this needs work, so I'm hoping someone will review and rework these small but helpful modules and add them to the official 5.x release. Thanks to anyone willing to polish this off!
#4
Changing version...
#5
Thanks!
My PHP is very weak so I can't really help with cleaning it up but I can test it out.
Michelle
#6
I've had no luck getting this to work. I can see in the code that it's adding extra options but they aren't showing up. Did you try this in 5.x?
Thanks,
Michelle
#7
Ok, I compared the code against the location module and made some blind changes. No clue what the difference is, but it seems to work.
At the top, I coped over 2 lines so it looks like:
function location_phone_form_alter($form_id, &$form) {if ($form_id == 'node_type_form') {
$type = $form['#node_type']->type;
For the other part, it now looks like:
elseif (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id && variable_get('location_maxnum_'. $form['type']['#value'], 0)) {$node = $form['#node'];
I don't know if there's anything else that needs to be changed. So far it seems to be working.
Michelle
#8
I did some more testing and the only thing I can find wrong is that the content type settings page keeps reverting back to do not collect on both phone and fax. The content type does allow me to enter them, though. So internally it realizes that I've set it; the setting just isn't reflecting that. Either that or it's ignoring the setting. Since I changed the setting before editing the node, I'm not sure which it is. I can do further testing a bit later to see which it is.
Michelle
#9
Sorry for the zillion posts. I don't know how long I'll be able to be on the computer before the baby wakes up so I keep giving all the info I have.
Anyway, I just confirmed that, with my changes, it adds the phone/fax to the form regardless of the settings. So it looks like the settings page isn't working and the form is ignoring the settings.
I don't know enough to know why, though. :(
Michelle
#10
Odd... I'm not a PHP guru myself, so most of what I did was copy over the phone module in 4.7 and then I built the .info files so the modules would at least be recognized in 5.0. There may be some coding changes that need to be updated in the little modules themselves. They are working on my site, but I already had data stored in those fields, so I'm not sure that makes a difference. Anyway, I hope someone with real expertise can make these completely viable. Thanks for testing... it's one step closer, at least.
#11
I've been thinking about this more and I'm not convinced separate modules are really needed. Each field has its own option, anyway, so having these as separate modules is just an extra step. I think it would make more sense to make a patch that adds these two fields to location.module where all the other ones are. What do you think?
Michelle
#12
Michelle, that sounds more efficient. I wonder what the maintainer of the module thinks? These aren't very big additions... so it seems prudent to just include them in the main project. Then again, I'm not a project maintainer.
#13
I went ahead and just ported the location_phone module to 4.7 (it involved changing 3 lines of code). I added a location_fax module. The location_fax module is just an exact copy of location_phone except it replace every occurrence of the word phone/Phone w/ fax/Fax, which is a less than ideal way of doing this. Ideally, I would've added some layer of abstraction that allows you do define an extra location field and whether this field should be numeric or not. Anyway, maybe I'll do something like that on the port to Drupal 6.
Also, note that the update does not change the theming of location in anyway, meaning that on the node-view, location phone numbers and location fax numbers simply aren't displayed. You have to change this yourself at the theme level. The key in the array are 'phone' and 'fax', respectively. I may, in the future, add some way automatically having the extra location fields added to the location view through some kind of internal (i.e., location-only) hook.
-Ankur
#14
Perfect! Thanks very much for doing this.
Michelle
#15