本文整理汇总了PHP中node_load_multiple函数的典型用法代码示例。如果您正苦于以下问题:PHP node_load_multiple函数的具体用法?PHP node_load_multiple怎么用?PHP node_load_multiple使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了node_load_multiple函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:enriquesanchezhernandez,项目名称:campaigns,代码行数:10,代码来源:WorkflowPublicationReviewManagerTest.php
示例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'));
}
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:40,代码来源:DateMigrateExampleUnitTest.php
示例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');
}
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:32,代码来源:NodeLoadMultipleTest.php
示例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')));
}
开发者ID:k-zafar,项目名称:barney_river,代码行数:36,代码来源:TeamMemberBlock.php
示例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;
}
开发者ID:bishopandco,项目名称:stlouishomesmag,代码行数:27,代码来源:template.php
示例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;
}
开发者ID:dingruoting,项目名称:tydaily,代码行数:27,代码来源:ClueController.php
示例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;
}
}
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:58,代码来源:MissingDatasetSymptom.php
示例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);
}
}
开发者ID:OPIN-CA,项目名称:ten_thousand_feet,代码行数:15,代码来源:ten_thousand_feet.api.php
示例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;
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:12,代码来源:Nid.php
示例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);
}
开发者ID:Samuel-Moncarey,项目名称:custom_sitemap,代码行数:13,代码来源:NodeImagesLoader.php
示例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);
}
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:Rss.php
示例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]);
}
开发者ID:City-of-Bloomington,项目名称:drupal-customizations,代码行数:14,代码来源:cob_directory.php
示例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);
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:14,代码来源:MigrateTermNodeTest.php
示例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;
}
开发者ID:jessicadigital,项目名称:drupalbase,代码行数:12,代码来源:SitemapController.php
示例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);
}
开发者ID:ec-europa,项目名称:platform-dev,代码行数:24,代码来源:DrupalContext.php
示例16: modulestarter_block_view
/**
* Implements hook_block_view();
* Define what a block defined in hook_block_info has to display
*/
function modulestarter_block_view($delta)
{
$block = array();
if ($delta == 'modulestarter_article_list') {
// appelle de notre classe métier pour générer le contenu d'un bloc
$article = new modulestarter_article();
$block['subject'] = t('Module starter example block');
// #theme is the template to used for rendering.
// #articles and others keys will be arguments passed to the theme function.
// @see hook_theme
$block['content'] = array('#theme' => 'modulestarter_article_list', '#articles' => node_load_multiple($article->get_list()));
}
return $block;
}
开发者ID:nyl-auster,项目名称:snippets,代码行数:18,代码来源:drupal-7--modulestarter-template.php
示例17: titleQuery
/**
* Override the behavior of title(). Get the title of the revision.
*/
public function titleQuery()
{
$titles = array();
$results = $this->database->query('SELECT nr.vid, nr.nid, npr.title FROM {node_revision} nr WHERE nr.vid IN (:vids)', array(':vids' => $this->value))->fetchAllAssoc('vid', PDO::FETCH_ASSOC);
$nids = array();
foreach ($results as $result) {
$nids[] = $result['nid'];
}
$nodes = node_load_multiple(array_unique($nids));
foreach ($results as $result) {
$nodes[$result['nid']]->set('title', $result['title']);
$titles[] = String::checkPlain($nodes[$result['nid']]->label());
}
return $titles;
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:18,代码来源:Vid.php
示例18: build
/**
* {@inheritdoc}
*/
public function build()
{
$query = \Drupal::entityQuery('node')->condition('status', 1)->condition('type', 'slideshow_slide')->sort('field_order', 'ASC');
$nids = $query->execute();
$nodes = node_load_multiple($nids);
$ind = 0;
$output_slide_add_logo = $output_slide = $output_slide_bullet = $output = '';
$logo = theme_get_setting('logo', 'zircon');
foreach ($nodes as $node) {
$output_slide_add_logo = "";
$class = $ind == 0 ? 'active' : '';
$output_slide_bullet .= '<li data-target="#myCarousel" data-slide-to="' . $ind . '" class="' . $class . '"></li>';
$path = $node->field_image->entity->url();
if ($node->field_add_logo->entity) {
$logo_path = explode("public://", $node->field_add_logo->entity->uri->value);
$output_slide_add_logo = '<div class="logo_on_slider">
<img src="sites/default/files/' . $logo_path[1] . '" alt="Logo">
</div>';
}
$output_slide .= '<div class="item ' . $class . '">
<img src="' . $path . '" alt="">
' . $output_slide_add_logo . '
</div>';
$ind++;
}
$output_slide_bullet_wrap = $ind > 1 ? '<ol class="carousel-indicators">' . $output_slide_bullet . '</ol>' : '';
$output = '<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
' . $output_slide_bullet_wrap . '
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
' . $output_slide . '
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>';
return array('#type' => 'markup', '#markup' => $output);
}
开发者ID:k-zafar,项目名称:barney_river,代码行数:51,代码来源:HomepageSlideshowBlock.php
示例19: findEntities
public static function findEntities ( array $params = array() ) {
$sql = 'SELECT entityId, entityType FROM {gd_role_permission} ';
$binds = array();
$where = array();
if ( !empty($params) ) {
foreach ( $params as $key => $value ) {
$binds[':'.$key] = $value;
$where[] = $key .' = :'.$key;
}
}
if ( !empty($where) ) {
$sql .= 'WHERE '.implode(' AND ',$where);
}
$result = db_query($sql,$binds);
if ( !$result || !$result->rowCount() ) {
return array();
}
$results = $result->fetchAll();
$entities = array();
if ( isset($params['entityType']) && $params['entityType'] === 'datasource' ) {
$datasources = gd_datasource_get_all();
foreach ( $datasources as $datasourceName => $DS ) {
foreach ( $results as $record ) {
if ( $record->entityId === $datasourceName ) {
$entities[$datasourceName] = $DS;
}
}
}
} else if ( isset($params['entityType']) && $params['entityType'] === 'dashboard' ) {
$dashboard_nids = array();
foreach ( $results as $record ) {
$dashboard_nids[] = $record->entityId;
}
$entities = node_load_multiple($dashboard_nids);
} else {
throw new \Exception('Unsupported EntityType');
}
return $entities;
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:46,代码来源:DrupalHelper.php
示例20: getExportables
public static function getExportables($datasourceName) {
if ( $datasourceName != gd_datasource_get_active() ) {
gd_datasource_set_active($datasourceName);
}
$metamodel = data_controller_get_metamodel();
// get datasets
$datasetNids = array();
foreach ($metamodel->datasets as $dataset) {
if (!isset($dataset->nid)) {
continue;
}
$datasetNids[] = $dataset->nid;
}
return node_load_multiple($datasetNids);
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:17,代码来源:DatasetExport.php
注:本文中的node_load_multiple函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论