本文整理汇总了PHP中node_view函数的典型用法代码示例。如果您正苦于以下问题:PHP node_view函数的具体用法?PHP node_view怎么用?PHP node_view使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了node_view函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: water_preprocess_page
/**
* Preprocess variables for page.tpl.php
* default variales for page.tpl.php:
* $logo, $front_page, $site_name, $site_slogan, $messages
* $title_prefix, $title_suffix, $tabs, $action_links
* $feed_icons, $breadcrumb
*/
function water_preprocess_page(&$vars)
{
if (isset($vars['node'])) {
// If the node type is "blog_madness" the template suggestion will be "page--blog-madness.tpl.php".
$vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
if ($vars['node']->type == 'deprecated_organization') {
//var_dump($vars['node']);
//$vars['organization_geolocation'] = array($vars['node']->field_latitude['und']['0']['value'], $vars['node']->field_longitude['und']['0']['value']);
/*
* LOAD GMAPS MODULE
*/
//add html element 'organization-gmap-canvas' in template file that will hold Google map
//Load gmap3_tools.inc file
module_load_include('inc', 'gmap3_tools');
//all gmap3_tools_add_map() function from API file with appropriate map configuratio array
gmap3_tools_add_map(array('mapId' => 'organization-gmap-canvas', 'mapOptions' => array('centerX' => -34.397, 'centerY' => 150.644, 'zoom' => 12), 'markers' => array(gmap3_tools_create_marker(-1, -1, 'Home', 'Home')), 'geocodeAddress' => $vars['node']->field_city['und']['0']['taxonomy_term']->name, 'gmap3ToolsOptions' => array('defaultMarkersPosition' => GMAP3_TOOLS_DEFAULT_MARKERS_POSITION_CENTER)));
}
//create a variable to hold rich title field added to specific content types
$view = node_view($vars['node']);
$vars['rich_title'] = render($view['field_rich_title']);
}
//var_dump($vars);
//var_export($vars);
//var_dump(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
// $vars['contact_form'] = drupal_render(drupal_get_form('contact_site_form'));
}
示例2: HOOK_builder_content_view
/**
* HOOK_builder_content_view()
*/
function HOOK_builder_content_view($delta = '', $content = array())
{
$content = '';
switch ($delta) {
case 'node':
$node_content = '';
if (!empty($content['settings']['nid'])) {
$nid = $content['settings']['nid'];
if ($node = node_load($nid)) {
if (isset($content['settings']['hide_node_title']) && $content['settings']['hide_node_title']) {
// hide node title.
$node->title = FALSE;
}
$node_view = node_view($node, $content['settings']['view_mode']);
$node_content = render($node_view);
}
}
$content['content'] = $node_content;
break;
case 'custom_text':
$custom_text_value = isset($content['settings']['custom_text']['value']) ? $content['settings']['custom_text']['value'] : '';
if (isset($content['settings']['custom_text']['format'])) {
$custom_text_value = check_markup($custom_text_value, $content['settings']['custom_text']['format']);
}
$content['content'] = $custom_text_value;
break;
return $content;
}
}
示例3: gallery
/**
* Gallery display.
*
* @return string
* Return Gallery output string.
*/
public function gallery() {
// Load the language manager service, so we can parse the user's current language.
$langcode = $this->languageManager()->getCurrentLanguage('language');
$photographs = $this->loadAllPhotos();
$view_mode = 'teaser';
$gallery = array();
// Loop through the loaded photograph node objects and output their rendered result into a list.
foreach ($photographs as $photograph) {
$render = node_view($photograph, $view_mode, $langcode);
$gallery[] = render($render);
}
// If the gallery is empty, we should apologise.
if (empty($gallery)) {
return [
'#type' => 'markup',
'#markup' => $this->t('Sorry, I have no photographs to share at the moment'),
'#prefix' => '<h2>',
'#suffix' => '</h2>',
];
}
// Return an item list of photographs for our gallery.
return [
'#theme' => 'item_list',
'#items' => $gallery,
];
}
示例4: contentOverview
/**
* Returns content for recent images.
*
* @return string
* A HTML-formatted string with the administrative page content.
*
*/
public function contentOverview() {
// @todo a lot of duplicate code can be consolidated in these controllers.
$query = db_select('node', 'n')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query->join('photos_album', 'p', 'p.pid = n.nid');
$query->fields('n', array('nid'));
$query->orderBy('n.nid', 'DESC');
$query->limit(10);
$query->addTag('node_access');
$results = $query->execute();
$output = '';
foreach ($results as $result) {
$node = \Drupal::entityManager()->getStorage('node')->load($result->nid);
$node_view = node_view($node, 'full');
$output .= \Drupal::service("renderer")->render($node_view);
}
if ($output) {
$pager = array(
'#type' => 'pager'
);
$output .= \Drupal::service("renderer")->render($pager);
}
else {
$output .= t('No albums have been created yet.');
}
return array(
'#markup' => $output
);
}
示例5: _pol_proc_admin_node_preview
/**
* Returns HTML for a node preview for display during node creation and editing.
*
* Overrides theme_node_preview() in modules/node/node.pages.inc.
*
* @param $variables
* An associative array containing:
* - node: The node object which is being previewed.
*
* @see node_preview()
* @ingroup themeable
*/
function _pol_proc_admin_node_preview($variables)
{
$node = $variables['node'];
$output = '<div class="preview">';
/*if ('policy' == $node->type) {
dsm($variables);
// Load the node into a context.
ctools_include('node_view', 'page_manager', 'plugins/tasks');
$elements = page_manager_node_view_page(clone $node);
$output .= drupal_render($elements);
drupal_add_css(drupal_get_path('theme', 'pol_proc_theme') . '/css/colors.css');
drupal_add_css(drupal_get_path('theme', 'pol_proc_theme') . '/css/site.css');
} elseif ('procedure' == $node->type) {
$output = _pol_proc_admin_node_procedure_preview($node);
} else { */
$preview_trimmed_version = FALSE;
$elements = node_view(clone $node, 'teaser');
$trimmed = drupal_render($elements);
$elements = node_view($node, 'full');
$full = drupal_render($elements);
// Do we need to preview trimmed version of post as well as full version?
if ($trimmed != $full) {
drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "<!--break-->" (without the quotes) to fine-tune where your post gets split.</span>'));
$output .= '<h3>' . t('Preview trimmed version') . '</h3>';
$output .= $trimmed;
$output .= '<h3>' . t('Preview full version') . '</h3>';
$output .= $full;
} else {
$output .= $full;
}
//}
$output .= "</div>\n";
return $output;
}
示例6: getNode
/**
* Drupal example
*/
public function getNode()
{
$node = new \erdiko\drupal\models\Node();
$post = $node->getNode(1);
$content = \drupal_render(\node_view($post));
$content .= "<pre>" . print_r($post, true) . "</pre>";
$this->setContent($content);
}
示例7: hook_proximity_ajax_render_item_alter
/**
* Returns the item specific content as render array or html string.
*
* The parameter $param contains the unique load parameter of the requested item.
*
* @param $container_index int Index of proximity container (if more than one container exists in one page).
* @param $param string The item specific load parameter (see also hook_proximity_ajax_load_params_alter).
* @param $render_item mixed The rendered content to be returned to the client. The $render_item should be
* replaced either by a string (rendered html content), a render array or an integer (error code).
*/
function hook_proximity_ajax_render_item_alter($container_index, $param, &$render_item)
{
// Example: the $param variable contains a node id (see hook_proximity_ajax_load_params_alter),
// return the render array for the specific node
if ($node = node_load($param)) {
$render_item = node_view($node);
}
}
示例8: execute
/**
* {@inheritdoc}
*/
public function execute($node = NULL)
{
foreach ($this->configuration['keywords'] as $keyword) {
$elements = node_view(clone $node);
if (strpos(drupal_render($elements), $keyword) !== FALSE || strpos($node->label(), $keyword) !== FALSE) {
$node->setPublished(FALSE);
$node->save();
break;
}
}
}
示例9: revisionShow
/**
* Displays a node revision.
*
* @param int $node_revision
* The node revision ID.
*
* @return array
* An array suitable for drupal_render().
*/
public function revisionShow($node_revision)
{
/** @var NodeInterface $node */
$node = $this->entityTypeManager()->getStorage('node')->loadRevision($node_revision);
// Determine view mode.
$view_mode = \Drupal::config('ds_extras.settings')->get('override_node_revision_view_mode');
drupal_static('ds_view_mode', $view_mode);
$page = node_view($node, $view_mode);
unset($page['nodes'][$node->id()]['#cache']);
return $page;
}
示例10: nbadraft_main_form_submit
function nbadraft_main_form_submit($form, &$form_status)
{
$form_status['rebuild'] = TRUE;
$draft_team_tid = $form_status['values']['draft_team'];
$draft_year_tid = $form_status['values']['draft_year'];
$nodes = get_draft_picks_for_team_year($draft_year_tid, $draft_team_tid);
$form_status['storage']['results'] = array();
foreach ($nodes as $node) {
$form_status['storage']['results'][] = node_view($node, 'teaser');
}
}
示例11: getValue
/**
* {@inheritdoc}
*/
public function getValue(ResultRow $values, $field = NULL)
{
$nid = parent::getValue($values, $field);
if (!is_null($nid)) {
// @todo Refactor to allow display price to be calculated.
$node = node_load($nid);
return $node->price->value;
// !TODO Refactor so that all variants are loaded at once in the pre_render hook.
$node = node_view(node_load($nid), 'teaser');
return $node['display_price']['#value'];
}
}
示例12: renderChart
/**
* Provides the replacement html to be rendered in place of the embed code.
*
* Does not handle nested embeds.
*
* @param array $matches
* Array of matches by preg_replace_callback
*
* @return string
* The rendered HTML replacing the embed code
*/
public function renderChart($matches)
{
/* @var $node \Drupal\Node\NodeInterface */
$node = Node::load($matches[1]);
if ($node == FALSE || !$node->isPublished() || !$node->access('view')) {
return "[[chart-nid:{$matches[1]},chart-view-mode:{$matches[2]}]]";
} else {
$view = node_view($node, $matches[2]);
$render = drupal_render($view);
return $render;
}
}
示例13: nodeView
public function nodeView($node, $view_mode = 'full')
{
if (empty($node)) {
return '';
}
if (is_array($node)) {
$build = node_view_multiple($node, $view_mode);
} else {
$build = node_view($node, $view_mode);
}
return drupal_render($build);
}
示例14: testTwigDebugMarkup
/**
* Tests debug markup added to Twig template output.
*/
function testTwigDebugMarkup()
{
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container->get('renderer');
$extension = twig_extension();
\Drupal::service('theme_handler')->install(array('test_theme'));
\Drupal::service('theme_handler')->setDefault('test_theme');
$this->drupalCreateContentType(array('type' => 'page'));
// Enable debug, rebuild the service container, and clear all caches.
$parameters = $this->container->getParameter('twig.config');
$parameters['debug'] = TRUE;
$this->setContainerParameter('twig.config', $parameters);
$this->rebuildContainer();
$this->resetAll();
$cache = $this->container->get('theme.registry')->get();
// Create array of Twig templates.
$templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme'));
$templates += drupal_find_theme_templates($cache, $extension, drupal_get_path('module', 'node'));
// Create a node and test different features of the debug markup.
$node = $this->drupalCreateNode();
$build = node_view($node);
$output = $renderer->renderRoot($build);
$this->assertTrue(strpos($output, '<!-- THEME DEBUG -->') !== FALSE, 'Twig debug markup found in theme output when debug is enabled.');
$this->setRawContent($output);
$this->assertTrue(strpos($output, "THEME HOOK: 'node'") !== FALSE, 'Theme call information found.');
$this->assertTrue(strpos($output, '* node--1--full' . $extension . PHP_EOL . ' x node--1' . $extension . PHP_EOL . ' * node--page--full' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' * node--full' . $extension . PHP_EOL . ' * node' . $extension) !== FALSE, 'Suggested template files found in order and node ID specific template shown as current template.');
$this->assertEscaped('node--<script type="text/javascript">alert(\'yo\');</script>');
$template_filename = $templates['node__1']['path'] . '/' . $templates['node__1']['template'] . $extension;
$this->assertTrue(strpos($output, "BEGIN OUTPUT from '{$template_filename}'") !== FALSE, 'Full path to current template file found.');
// Create another node and make sure the template suggestions shown in the
// debug markup are correct.
$node2 = $this->drupalCreateNode();
$build = node_view($node2);
$output = $renderer->renderRoot($build);
$this->assertTrue(strpos($output, '* node--2--full' . $extension . PHP_EOL . ' * node--2' . $extension . PHP_EOL . ' * node--page--full' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' * node--full' . $extension . PHP_EOL . ' x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.');
// Create another node and make sure the template suggestions shown in the
// debug markup are correct.
$node3 = $this->drupalCreateNode();
$build = array('#theme' => 'node__foo__bar');
$build += node_view($node3);
$output = $renderer->renderRoot($build);
$this->assertTrue(strpos($output, "THEME HOOK: 'node__foo__bar'") !== FALSE, 'Theme call information found.');
$this->assertTrue(strpos($output, '* node--foo--bar' . $extension . PHP_EOL . ' * node--foo' . $extension . PHP_EOL . ' * node--<script type="text/javascript">alert('yo');</script>' . $extension . PHP_EOL . ' * node--3--full' . $extension . PHP_EOL . ' * node--3' . $extension . PHP_EOL . ' * node--page--full' . $extension . PHP_EOL . ' * node--page' . $extension . PHP_EOL . ' * node--full' . $extension . PHP_EOL . ' x node' . $extension) !== FALSE, 'Suggested template files found in order and base template shown as current template.');
// Disable debug, rebuild the service container, and clear all caches.
$parameters = $this->container->getParameter('twig.config');
$parameters['debug'] = FALSE;
$this->setContainerParameter('twig.config', $parameters);
$this->rebuildContainer();
$this->resetAll();
$build = node_view($node);
$output = $renderer->renderRoot($build);
$this->assertFalse(strpos($output, '<!-- THEME DEBUG -->') !== FALSE, 'Twig debug markup not found in theme output when debug is disabled.');
}
示例15: pixelgarage_proximity_ajax_render_item_alter
/**
* Returns the item specific content as render array or html string. The $param attribute contains the item specific parameter
* added to the ajax request.
*
* @param $container_index int Index of proximity container (if more than one container exists in one page).
* @param $param string The item specific load parameter (see also hook_proximity_ajax_load_params_alter).
* @param $render_item mixed The rendered content to be returned to the client. The $render_item should be
* replaced either by a string (rendered html content), a render array or an integer (error code).
*/
function pixelgarage_proximity_ajax_render_item_alter($container_index, $param, &$render_item)
{
// return the render array for the specific node, if available
if ($node = node_load($param)) {
$view_mode = 'full';
if (property_exists($node, 'ds_switch')) {
// take an alternate view mode set by the ds switch
$view_mode = $node->ds_switch;
}
$render_item = node_view($node, $view_mode);
}
}