I'd like to be able to load a node based on its' type and the domain to which it belongs.

Now, finding a node based on type is pretty straight forward; I just do a :


$node = node_load(array('type' => 'story'));

This doesn't work:

$node = node_load(array('type' => 'story', 'domains' => array('2' => '2'));

I couldn't figure out a programatic way to find a node that is a particular type and that belongs to a particular domain. Instead, I'm just doing it manually thru SQL, joining the node and domain_access table.

Is there a 'recommended' way to programatically get a node that belongs to a particular domain?

TIA

Comments

agentrickard’s picture

Other than using Views, no. Core node_load() does not allow JOINs to other tables.

Doing a join to {domain_access} should be fine (and properly indexed).

agentrickard’s picture

Status: Active » Closed (fixed)