Created
September 11, 2012 19:55
-
-
Save baisong/3701570 to your computer and use it in GitHub Desktop.
attempt to create EntityFieldQuery accounting for vsite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Returns a new EntityFieldQuery in the current space, if vsite is enabled. | |
| */ | |
| function _os_node_query($type = '') { | |
| // Prepares a new EntityFieldQuery for nodes. | |
| $query = new EntityFieldQuery(); | |
| $query->entityCondition('entity_type', 'node'); | |
| // Adds node type condition if given | |
| if (isset($type) && strlen($type) > 0) { | |
| dpm($type); | |
| $query->entityCondition('bundle', $type); | |
| } | |
| $query->propertyCondition('status', 1); | |
| // Returns if we are running a single-tenant installation. | |
| if (!module_exists('vsite')) { | |
| return $query; | |
| } | |
| // Returns if we cannot load the current space. | |
| $space = spaces_get_space(); | |
| if (!is_numeric($space->id)) { | |
| return $query; | |
| } | |
| // Adds field condition for OG audience if available. | |
| $query->fieldCondition(OG_AUDIENCE_FIELD, 'target_id', $space->id); | |
| return $query; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment