This is mostly a best practice question; here's the setup. I'm creating a small app to manage characters for a tabletop game.
- I have content types for Character, Armor, and Character Inventory.
- Armor has a field called Defense, let's say it's 3 in this example.
- Character Inventory uses node reference to link the Character to the Armor, creating a single instance. This node has an extra Bonus field, let's say 2.
- A Character has a second piece of Armor in his inventory, with the second piece having a Defense of 2 and an extra Bonus of 0.
Currently the user sees a character node, followed by two Views Attach tables displaying current Armor and Weapon inventory. My goal is to present a Total Defense stat on the character node, which is now 7 in the above example. I don't think I can use a view, because the Views Attach piece runs and renders after the node.
I could use db_fetch_object(db_query($myquery)) to pull the info, but is there a more clever or easier way to handle this? CCK Computed Field (which I'm also using extensively) doesn't seem applicable here. And if I'm already writing one query, I don't see an advantage to using Views at all here when I could do the whole page this way and build my own Inventory tables.
Thoughts?