Closed (won't fix)
Project:
Content Construction Kit (CCK)
Version:
5.x-1.x-dev
Component:
General
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Nov 2008 at 19:18 UTC
Updated:
9 Jun 2010 at 13:01 UTC
When people use nodes for profiles, there are some fields that they may want to grab the data from without doing a full node load. It would be handy to have a generic API function where you can give it a node id and a field name and get the value for that field on that node.
So my first question is, does such a function already exist? If not, would you be willing to add it (preferably to both D5 and D6)? And my pie in the sky question... Would you be willing to write it? LOL! If the answers are "no", "yes", and "no", I'll take a stab at a patch myself. Hints appreciated. :)
Thanks,
Michelle
Comments
Comment #1
karens commentedI'm not sure you'd save anything by doing this -- the node value is cached so the only thing a node_load() does is pull up the cached value from the database. Doing a custom SQL query to get specific values will be at least as expensive as doing that and will bypass the node hooks, which means important information might be left out.
Comment #2
yched commentedWell, i guess we could build a function that retrieves a single field, from the cache if available, or from the db, like content_load() does for all fields.
But as Karen points out, bypassing node_load misses possible alterations other modules might make in their own hook_nodeapi('load').
Comment #3
michelleThe caching of node_load doesn't help on the first call, which is what this would be most of the time. Imagine you have a forum thread with 50 posts shown on one page. In a worst case scenario, each of these 50 posts is by a different user. So none of them would be cached and you'd have 50 node loads. In a real world situation there would likely be people posting more than once so you would get the benefit of caching there but there could still be a lot of loads just to get out one or maybe a couple fields and throw the rest away.
Michelle
Comment #4
karens commentedToo old now, way past the time when we will add features to D5 version. Sorry this never got addressed. We're really not even adding features to D6. If this still applies and you think it should be added to the current code you can let us know.
Comment #5
michelleI could still use it in D6 but I still don't know how to write it. Since I'm not volunteering and I'm sure you're busy with D7 stuff, I understand if you keep this won't fix. Content Profile has a work around for the specific use case I gave in my example so I guess that will just be good enough.
I haven't looked at D7 at all, yet, so I don't know if this is even still an issue there. If it is, would you consider adding the functionality to D7?
Michelle
Comment #6
michelleOh, I suppose I should set this active so you see my response but I understand if you put it right back to won't fix. :)
Michelle
Comment #7
karens commentedWell it would be a core issue in D7 and I don't know how much chance there is of getting it done there :)
The D7 change is outside our scope of influence.
Comment #8
michelleAh, downside to CCK in core. Ok, thanks for letting me know. Maybe when I get that far I'll write a contrib module to do it or something. Being able to get the value of a field without loading the whole node is one of those things that seems like a no brainer to me but I guess no one has gotten that "itch".
Michelle