本文整理汇总了PHP中node_load_multiple函数的典型用法代码示例。如果您正苦于以下问题:PHP node_load_multiple函数的具体用法?PHP node_load_multiple怎么用?PHP node_load_multiple使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了node_load_multiple函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanup
/**
* {@inheritdoc}
*/
public function cleanup()
{
$nodes = node_load_multiple(array(), array('title' => $this->nodeTitle1), TRUE);
node_delete_multiple(array_keys($nodes));
$nodes = node_load_multiple(array(), array('title' => $this->nodeTitle2), TRUE);
node_delete_multiple(array_keys($nodes));
}
示例2: testDateImport
/**
* Verify that date fields are imported correctly. When no timezone is
* explicitly provided with the source data, we want the displayed time on the
* Drupal site to match that in the source data. To validate that, we make
* sure we have set a consistent timezone at the PHP and Drupal levels, and
* that the format used on the page is not locale-dependent (no day or month
* names). Then, we can just look for the desired date/time strings in the
* node page.
*/
function testDateImport()
{
date_default_timezone_set('America/Los_Angeles');
variable_set('date_default_timezone', 'America/Los_Angeles');
variable_set('date_format_medium', 'Y-m-d H:i');
$migration = Migration::getInstance('DateExample');
$result = $migration->processImport();
$this->assertEqual($result, Migration::RESULT_COMPLETED, t('Variety term import returned RESULT_COMPLETED'));
$rawnodes = node_load_multiple(FALSE, array('type' => 'date_migrate_example'), TRUE);
$this->assertEqual(count($rawnodes), 2, t('Two sample nodes created'));
$node = reset($rawnodes);
$this->drupalGet('/node/' . $node->nid);
$this->assertText('2011-05-12 19:43', t('Simple date field found'));
$this->assertText('2011-06-13 18:32 to 2011-07-23 10:32', t('Date range field found'));
$this->assertText('2011-07-22 12:13', t('Datestamp field found'));
$this->assertText('2011-08-01 00:00 to 2011-09-01 00:00', t('Datestamp range field found'));
$this->assertText('2011-11-18 15:00', t('Datetime field with +9 timezone found'));
$this->assertText('2011-10-30 14:43 to 2011-12-31 17:59', t('Datetime range field with -5 timezone found'));
$this->assertText('2011-11-25 09:01', t('First date repeat instance found'));
$this->assertText('2011-12-09 09:01', t('Second date repeat instance found'));
$this->assertNoText('2011-12-23 09:01', t('Skipped date repeat instance not found'));
$this->assertText('2012-05-11 09:01', t('Last date repeat instance found'));
$node = next($rawnodes);
$this->drupalGet('/node/' . $node->nid);
$this->assertText('2012-06-21 15:32', t('First date value found'));
$this->assertText('2012-12-02 11:08', t('Second date value found'));
$this->assertText('2004-02-03 01:15', t('Start for first date range found'));
$this->assertText('2005-03-04 22:11', t('End for first date range found'));
$this->assertText('2014-09-01 17:21', t('Start for second date range found'));
$this->assertText('2015-12-23 00:01', t('End for first second range found'));
}
示例3: testNodeMultipleLoad
/**
* Creates four nodes and ensures that they are loaded correctly.
*/
function testNodeMultipleLoad()
{
$node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
$node2 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
$node3 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 0));
$node4 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 0));
// Confirm that promoted nodes appear in the default node listing.
$this->drupalGet('node');
$this->assertText($node1->label(), 'Node title appears on the default listing.');
$this->assertText($node2->label(), 'Node title appears on the default listing.');
$this->assertNoText($node3->label(), 'Node title does not appear in the default listing.');
$this->assertNoText($node4->label(), 'Node title does not appear in the default listing.');
// Load nodes with only a condition. Nodes 3 and 4 will be loaded.
$nodes = entity_load_multiple_by_properties('node', array('promote' => 0));
$this->assertEqual($node3->label(), $nodes[$node3->id()]->label(), 'Node was loaded.');
$this->assertEqual($node4->label(), $nodes[$node4->id()]->label(), 'Node was loaded.');
$count = count($nodes);
$this->assertTrue($count == 2, format_string('@count nodes loaded.', array('@count' => $count)));
// Load nodes by nid. Nodes 1, 2 and 4 will be loaded.
$nodes = node_load_multiple(array(1, 2, 4));
$count = count($nodes);
$this->assertTrue(count($nodes) == 3, format_string('@count nodes loaded', array('@count' => $count)));
$this->assertTrue(isset($nodes[$node1->id()]), 'Node is correctly keyed in the array');
$this->assertTrue(isset($nodes[$node2->id()]), 'Node is correctly keyed in the array');
$this->assertTrue(isset($nodes[$node4->id()]), 'Node is correctly keyed in the array');
foreach ($nodes as $node) {
$this->assertTrue(is_object($node), 'Node is an object');
}
}
示例4: build
/**
* {@inheritdoc}
*/
public function build()
{
$query = \Drupal::entityQuery('node')->condition('status', 1)->condition('type', 'team_member')->sort('field_order', 'ASC');
$nids = $query->execute();
$nodes = node_load_multiple($nids);
//$nodes = entity_load_multiple('node', $nids);
$ind = 1;
$output = '<div class="tabbable tabs-left tabcordion">
<ul class="nav nav-tabs">';
foreach ($nodes as $node) {
$class = $ind == 1 ? 'active' : '';
$output .= '<li class="' . $class . '"><a data-target="#team_member_tab' . $ind . '" data-toggle="tab">' . $node->title->value . '<span>' . $node->get('field_designation')->value . '</span></a></li>';
$ind++;
}
$ind = 1;
$output .= '</ul>
<div class="tab-content">';
foreach ($nodes as $node) {
$class = $ind == 1 ? 'active' : '';
if (is_object($node->field_image->entity)) {
$path = $node->field_image->entity->getFileUri();
$url = ImageStyle::load('person_picture')->buildUrl($path);
$tab_content_html = '<div class="row"><div class="col-md-3"><img src="' . $url . '" alt=""></div><div class="col-md-9">' . $node->get('body')->value . '</div> </div>';
} else {
$tab_content_html = '<div>' . $node->get('body')->value . '</div>';
}
$output .= '<div class="tab-pane ' . $class . '" id="team_member_tab' . $ind . '"> ' . $tab_content_html . ' </div>';
$ind++;
}
$output .= '</div>
</div>';
return array('#type' => 'markup', '#markup' => $output, '#attached' => array('library' => array('barney_river_utilities/tabcordion', 'barney_river_utilities/tabcordion_hook')));
}
示例5: getRelatedPosts
function getRelatedPosts($ntype, $nid)
{
$nids = db_query("SELECT n.nid, title FROM {node} n WHERE n.status = 1 AND n.type = :type AND n.nid <> :nid ORDER BY RAND() LIMIT 0,2", array(':type' => $ntype, ':nid' => $nid))->fetchCol();
$nodes = node_load_multiple($nids);
$return_string = '';
if (!empty($nodes)) {
foreach ($nodes as $node) {
$field_image = field_get_items('node', $node, 'field_image_blog');
$return_string .= '<li class="item content-in col-md-6"><div class="widget-post-wrap">';
$return_string .= '<div class="thumb"><a href="' . url("node/" . $node->nid) . '">';
$return_string .= '<img src="' . file_create_url($node->field_image['und'][0]['uri']) . '" alt="' . $node->title . '">';
$return_string .= '</a></div>';
$return_string .= '<div class="article-content-wrap">';
$return_string .= '<h4 class="title"><a href="' . url("node/" . $node->nid) . '">';
$return_string .= $node->title . '</a></h4>';
$return_string .= '<div class="excerpt">' . substr($node->body['und'][0]['value'], 0, 100) . '...' . '</div>';
$return_string .= '<div class="meta-bottom">';
/* $return_string .= '<div class="post-cat"><span><i class="fa fa-folder"></i></span>'.strip_tags(render($content['field_blog_category']),'<a>').'</div>';*/
$return_string .= '<div class="post-date"><span><i class="fa fa-clock-o"></i></span>' . format_date($node->created, 'custom', 'M j,Y') . '</div>';
$return_string .= '<div class="meta-comment"><span><i class="fa fa-comments-o"></i></span><a href="' . url("node/" . $node->nid) . '">' . $node->comment_count . '</a></div>';
$return_string .= '</div></div>';
$return_string .= '<a class="bk-cover-link" href="' . url("node/" . $node->nid) . '"></a></div>';
$return_string .= '</li>';
}
}
return $return_string;
}
示例6: actionList
public function actionList()
{
$sels = new Sels();
$easyNewsall = array();
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'clue')->propertyOrderBy('nid', 'DESC')->propertyCondition('status', 1)->range(0, 20);
if (isset($_POST['lastnewsid'])) {
$query->propertyCondition('nid', $_POST['lastnewsid'], '<');
}
$result = $query->execute();
if (isset($result['node'])) {
$news_items_nids = array_keys($result['node']);
$news = node_load_multiple($news_items_nids);
}
foreach ($news as $new) {
$easyNews['id'] = $new->nid;
$easyNews['title'] = $new->title;
$easyNews['img1'] = str_replace("public://", BigImg, $new->field_tux['und'][0]['uri']);
array_push($easyNewsall, $easyNews);
}
$sels->articles = $easyNewsall;
$jsonObj = CJSON::encode($sels);
/* if(isset($key))
$cache->set($key,$jsonObj,0,new CDbCacheDependency('select max(id) from tbl_dblogs'));
*/
echo $jsonObj;
}
示例7: scanReports
private function scanReports () {
$this->affected = array();
$query = new \EntityFieldQuery();
$query->entityCondition('entity_type', 'node');
$query->propertyCondition('type', NODE_TYPE_REPORT);
$query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
$result = $query->execute();
$reportNids = isset($result['node']) ? array_keys($result['node']) : NULL;
$reportNodes = node_load_multiple($reportNids);
foreach ( $reportNodes as $node ) {
$datasetName = get_node_field_value($node,'field_report_dataset_sysnames');
if ( empty($datasetName) ) {
$patient = array(
'info' => array(
'reportNodeId' => $node->nid,
'reportTitle' => $node->title,
'published' => $node->status,
'type' => $node->type,
'datasetName' => $datasetName
),
'notes' => 'Dataset field is empty.'
);
$this->attachTreatment($patient);
$this->affected[] = $patient;
continue;
}
// lookup dataset
$datasourceQuery = new \EntityFieldQuery();
$datasourceQuery->entityCondition('entity_type', 'node');
$datasourceQuery->propertyCondition('type', NODE_TYPE_DATASET);
$datasourceQuery->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
$datasourceQuery->fieldCondition('field_dataset_sysname', 'value', $datasetName);
$datasourceQuery->fieldCondition('field_dataset_datasource', 'value', get_node_field_value($node,'field_report_datasource'));
$datasourceEntities = $datasourceQuery->execute();
$datasource_nids = isset($datasourceEntities['node']) ? array_keys($datasourceEntities['node']) : NULL;
if (count($datasource_nids) != 1) {
$patient = array(
'info' => array(
'reportNodeId' => $node->nid,
'reportTitle' => $node->title,
'published' => $node->status,
'type' => $node->type,
'datasetName' => $datasetName
),
'notes' => 'Dataset does not exist.'
);
$this->attachTreatment($patient);
$this->affected[] = $patient;
continue;
}
}
}
示例8: _ten_thousand_feet_get_all_projects
/**
* Get all project (nodes) from Drupal
*
* @param string $url
* @return string $data
*/
function _ten_thousand_feet_get_all_projects()
{
try {
return node_load_multiple(array(), array('type' => 'project'));
} catch (Exception $e) {
# Log the exception to watchdog.
watchdog_exception('database', $e);
}
}
示例9: titleQuery
/**
* Override the behavior of title(). Get the title of the node.
*/
public function titleQuery()
{
$titles = array();
$nodes = node_load_multiple($this->value);
foreach ($nodes as $node) {
$titles[] = String::checkPlain($node->label());
}
return $titles;
}
示例10: loadNodesWithImages
/**
* Loads all nodes that have associated images.
* @return Array of nodes
*/
function loadNodesWithImages()
{
$query = db_select('file_usage', 'u');
$query->join('node', 'n', 'u.id = n.nid');
$query->fields('u', ['id'])->condition('n.status', NODE_PUBLISHED);
$result = $query->execute();
$nids = array_keys($result->fetchAllAssoc('id'));
return node_load_multiple($nids);
}
示例11: preRender
public function preRender($values)
{
$nids = array();
foreach ($values as $row) {
$nids[] = $row->{$this->field_alias};
}
if (!empty($nids)) {
$this->nodes = node_load_multiple($nids);
}
}
示例12: _cob_directory
/**
* Displays the list of department nodes and their contact info
*/
function _cob_directory()
{
$d = node_load_multiple([], ['type' => 'department']);
usort($d, function ($a, $b) {
if ($a->title == $b->title) {
return 0;
}
return $a->title < $b->title ? -1 : 1;
});
return theme('cob_directory', ['departments' => $d]);
}
示例13: testTermNode
/**
* Tests the Drupal 6 term-node association to Drupal 8 migration.
*/
public function testTermNode()
{
$nodes = node_load_multiple(array(1, 2), TRUE);
$node = $nodes[1];
$this->assertEqual(count($node->vocabulary_1_i_0_), 1);
$this->assertEqual($node->vocabulary_1_i_0_[0]->target_id, 1);
$node = $nodes[2];
$this->assertEqual(count($node->vocabulary_2_i_1_), 2);
$this->assertEqual($node->vocabulary_2_i_1_[0]->target_id, 2);
$this->assertEqual($node->vocabulary_2_i_1_[1]->target_id, 3);
}
示例14: getContent
protected function getContent($type = 'page')
{
$content = array();
$result = \Drupal::entityQuery('node')->condition('type', $type)->condition('status', 1)->execute();
if (!empty($result)) {
$nodes = node_load_multiple($result);
foreach ($nodes as $node) {
$content[] = ['title' => $node->getTitle(), 'url' => $node->url()];
}
}
return $content;
}
示例15: visitContentPage
/**
* Visit a node page given its type and title.
*
* @param string $type
* The node type.
* @param string $title
* The node title.
*
* @Then I visit the :type content with title :title
*/
public function visitContentPage($type, $title)
{
$nodes = node_load_multiple([], ['title' => $title, 'type' => $type], TRUE);
if (!$nodes) {
throw new \InvalidArgumentException("Node of type '{$type}' and title '{$title}' not found.");
}
// Get node path without any base path by setting 'base_url' and 'absolute'.
$node = array_shift($nodes);
$path = 'node/' . $node->nid;
cache_clear_all($path, 'cache_path');
$path = url($path, ['base_url' => '', 'absolute' => TRUE]);
// Visit newly created node page.
$this->visitPath($path);
}