Guessing array key for object type...

cwells - June 3, 2008 - 20:34
Project:netFORUM Dynamic Facade Nodes
Version:5.x-0.8-8
Component:Code
Category:support request
Priority:normal
Assigned:james.michael-hill
Status:active
Description

First of all, THANK YOU for this module. Brilliant!

Anyway, around line 1582 of netforum_node.module, first it checks if a "netforum_object_key_field" function exists... if it does, then we need to upgrade to a new version of the base netforum module (upgrade_needed = true).

Then in the next branch it says if they "HAVEN'T" upgraded to the new version in that next branch. This seems to be a contradiction. That's not really my issue though... my issue is that I've got a view of the object type "ProductMerchandise" -- the correct array key there is "mer_prd_key" but my prefix is "mer", and your code is guessing and appending "mer_cst_key," and so can't match up/auto-create nodes for me (which, again, is ingenius... love the way this integrates).

So... is there a better way to be "guessing" the array keys there, or is the code a little different and I SHOULD have a netforum_object_key_field function?

Thanks!

#1

james.michael-hill - September 1, 2008 - 01:52
Assigned to:Anonymous» james.michael-hill

Glad you like it! I had a good time writing it and good to see it getting some use. First up, you're spot on about the upgrade needed value, I've broken that out to an else block so it sets it like I intended - thanks for that.

I think you should have the netforum_object_key_field function in the netforum module if you have the latest version, and that one should check the database to get the real key field.

#2

cwells - September 1, 2008 - 21:10

I changed line 1590 to:
$obj_key_field = $object_data[$obj_prefix ."_key"] ? $obj_prefix ."_key" : ($obj_prefix != 'mer' ? $obj_prefix ."_cst_key" : $obj_prefix ."_prd_key");

So basically if it doesn't start with "mer" (merchandise) then use the _cst_key, suffix but if it does, then use "_prod_key" instead. I don't know NetForum well enough to say if this is sound logic, but it worked for my particular site.

 
 

Drupal is a registered trademark of Dries Buytaert.