You are here

function service_links_render in Service links 6.2

Same name and namespace in other branches
  1. 5 service_links.module \service_links_render()
  2. 6 service_links.module \service_links_render()
  3. 7.2 service_links.module \service_links_render()

Function that render all the selected services.

Parameters

$node: Contains the content structured as a node object. Use the node_load() function to build one or set NULL this variable to consider the current page.

$nodelink: (optional) It determines the kind of render. If TRUE the function return an array of items compatible with the standard Drupal link section. If FALSE return an array of HTML links. Default is FALSE.

$options: (optional) Can assume the value of a valid service style either an array containing the settings to override (look at _service_links_load_settings() for more details).

Return value

An array of HTML links if $nodelink = FALSE, an array of structured links to be themed with theme_links() if $nodelink = TRUE.

10 calls to service_links_render()
service_links_block in ./service_links.module
Implementation of hook_block().
service_links_handler_field_service_links::render in ./service_links_handler_field_service_links.inc
service_links_link in ./service_links.module
Implementation of hook_link().
service_links_nodeapi in ./service_links.module
Implementation of hook_nodeapi().
themename_preprocess in ./template.php
If something doesn't work well try this.

... See full list

File

./service_links.module, line 475
Adds social network links to the content.

Code

function service_links_render($node, $nodelink = FALSE, $options = NULL) {
  $links = array(
    'weight' => array(),
    'link' => array(),
  );
  $settings = _service_links_load_settings();
  if (empty($settings['link_show'])) {
    return array();
  }
  if (isset($options)) {
    if (!is_array($options)) {
      $options = array(
        'style' => $options,
      );
    }
    $settings = array_merge($settings, $options);
  }
  _service_links_get_tags($node, $settings);

  // Services are filtered in _service_links_load_settings().
  $services = service_links_get_links($settings['link_show']);
  foreach ($services as $service_id => $service) {

    // Load the position.
    $links['weight'][] = isset($settings['link_weight'][$service_id]) ? $settings['link_weight'][$service_id] : 0;

    // Render the Service.
    $links['link'] += _service_links_render($service_id, $service, $settings, $nodelink, $node);
  }
  if (!empty($links['link'])) {
    array_multisort($links['weight'], $links['link']);
  }
  return !empty($links['link']) ? $links['link'] : array();
}