示例#1
0
/**
 * Implements hook_process_node().
 */
function osha_frontend_process_node(&$vars)
{
    // Change default text of the read more link.
    if ($vars['type'] != 'press_release' && $vars['view_mode'] == 'full') {
        if (isset($vars['content']['links']['print_pdf'])) {
            // only press release could be downloaded as pdf
            unset($vars['content']['links']['print_pdf']);
        }
    }
    if ($vars['type'] == 'publication' && $vars['view_mode'] == 'full') {
        fill_related_publications($vars);
    }
    // CW-1087 - publications opens at alias/view link.
    if ($vars['type'] == 'publication' && !empty($vars['content']['links']['node']['#links']['node-readmore'])) {
        $url =& $vars['content']['links']['node']['#links']['node-readmore']['href'];
        $path = path_load($url);
        if (!empty($path)) {
            $url = $path['alias'] . '/view';
        } else {
            $url .= '/view';
        }
    }
    if (isset($vars['content']['links']['node']['#links']['node-readmore'])) {
        $vars['content']['links']['node']['#links']['node-readmore']['title'] = t('Show details');
    }
    /*insert views blocks - disabled for the moment
      add_blocks_inside_content($vars);*/
}
示例#2
0
<?php

/**
 * @file update_aliases.php
 *
 * Drush script for removing the prefixed / from the courses aliases.
 *
 * @example:
 *
 *   drush scr update_aliases.php
 */
if (!drupal_is_cli()) {
    // The file is not reachable via web browser.
    return;
}
// Iterate over the elements.
$results = db_select('url_alias', 'u')->fields('u', array('pid'))->condition('alias', '/courses%', 'LIKE')->execute()->fetchAllAssoc('pid');
if (!$results) {
    return;
}
foreach (array_keys($results) as $pid) {
    $path = path_load(array('pid' => $pid));
    $params['@url'] = $path['alias'];
    $path['alias'] = str_replace('/courses', 'courses', $path['alias']);
    path_save($path);
    $sandbox['pid'] = $params['@pid'] = $path['pid'];
    drush_log(dt('Updating @url(@pid)', $params), 'success');
}