Active
Project:
GMap Addons
Version:
5.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Jul 2007 at 03:12 UTC
Updated:
26 Jul 2007 at 10:20 UTC
I am trying to display the map in a block on sidebar. Here is function that i have been playing with to do this job.
gmap_cck_field_formatter($field, $item, $formatter, $node)
$item: I pass that value stored for gmap_cck type field on the node
$formatter: I don't pass anything. it seems to take 'default'
$node: I pass $node
$field: This seems to have complete definition of that gmap_cck type field. And i don't know how to get this field definition. WHAT DO I NEED TO PASS FOR THIS PARAMETER?
Is there a better way to display the map in a block for the node?
Comments
Comment #1
ray007 commentedI haven't displayed a block in a sidebar, but I remember having seen a module "node as block" or something like that, maybe that could help.
That said, you shouldn't call gmap_cck_field_formatter() directly, but rather content_format() instead.
In order to work you can pass the fieldname of the gmap_cck field (i.e. 'field_myfield') as first parameter to content_format().
If you succeed please post here how you did it.
Comment #2
zigma commentedThank you ray,
I tried that. It seems the function is not able to get widget related info. It just throws text instead of rendering the map.
Comment #3
zigma commentedSeems like content_format does make right call. However gmap_cck_field_formatter
is not doing the job.
Comment #4
zigma commentedNow i find something weird.
when i directly call function gmap_cck_field_formatter passing field name (which is field_my_loc_map) for $field. It displays the map.
print gmap_cck_field_formatter('field_my_loc_map', $node->field_my_loc_map[0], '', $node);But the above call throws two warnings-
####################
warning: Invalid argument supplied for foreach() in d:\apache group\Apache\~ ~ ~\modules\gmap_addons\gmap_cck.module on line 518.
warning: array_merge() [function.array-merge]: Argument #2 is not an array in d:\apache group\Apache\~ ~ ~\modules\gmap_addons\gmap_cck.module on line 279
####################
Here is what i find at those 2 lines--
Line #518: foreach ($nrf as $delta => $item) {
Line #279: $map = array_merge(gmap_defaults(), $field, $m);
When i build array for field and call gmap_cck_field_formatter like-
It does not display that warning. But it does not display the map as well.
Calling content_format() does exactly that. It passes an array for $field. Therefore it does not throw any warning but it does not display map as well.
Comment #5
ray007 commented1. don't use gmap_cck_field_formatter() directly, use content_format() instead
2. don't pass an empty string as 3rd parameter (formatter), use 'default' instead
for the warning insert the following code in line 516 (after $fname = ...):
I'll do a new release a bit later.
Comment #6
zigma commentedray,
thank you for quick help.
When i use content_format(), i don't get any warning with or without that statement to be inserted at #516.
print content_format('field_test_location_map', $node->field_my_loc_map[0], 'default', $node);However it does not display any map. I can see that field on page source though. So it seems all the formatting are not done properly.
When i use the following call.
print content_format('field_test_location_map', $node->field_my_loc_map[0], 'default', $node);a) it displays the map
b) with that statement at line#516, one of the warning is gone. However one of them referring to line#279 is still there
Comment #7
ray007 commentedIf the warning in line 279 is still there, then your first parameter to content_format() seems to be wrong. Looking at your example, I'd expect the line to look like this:
And a small correction of my last statement: the value of the formatter argument (parameter 3) currently doesn't matter. But it's still a good idea to not pass it empty ;-)
Comment #8
zigma commented>>>then your first parameter to content_format() seems to be wrong
I tried creating a new field to test it. that's why you found different field name in my last message.
I still observe the same behavior-
1) with content_format()
a) no warning
b) map does not show up even though i can see it takes some blank space on screen
2) with gmap_cck_field_formatter()
a) throws warning at line#279
b) map shows up
Comment #9
ray007 commentedIf you use gmap_cck_field_formatter() directly, you cannot use the fieldname as first paramter.
What's the result of
$field = content_fields('field_my_loc_map');?Because if you don't get a valid field configuration array here, the whole thing cannot work.
That would also explain the call to content_format() not working - the content module cannot find the field definition you're asking it for.
Comment #10
zigma commentedok. here is what i find in html source. this seems to be related to calls to theming function-
This one has been generated using content_format, that does not display-
####################################################
####################################################
####################################################
####################################################
And this one has been generated using gmap_cck_field_formatter() and the map shows up in this case-
This one seem to ignore custom size defined for the field. Instead it takes default size information and probably other properties as well from gmap module.
Comment #11
zigma commentedresult of $field = content_fields('field_test_location_map');
Comment #12
zigma commentedray,
Let me know if you would like me to try out few things.
Comment #13
ray007 commentedTry to use http://drupal.org/project/nodeasblock
Can't do debugging custom code here, that does not work.