示例#1
0
文件: template.php 项目: aakb/alice
/**
 * Node preprocessing
 */
function alice_preprocess_node(&$vars)
{
    // Get node object
    $node = $vars['node'];
    // Create pushlished date
    $vars['published'] = _alice_create_by($node->uid, $node->created);
    // Create status
    $vars['status'] = $node->field_wish_status[0]['view'] != NULL ? $node->field_wish_status[0]['view'] : t('Unknown status');
    // Get category
    $category = _alice_get_category($node->taxonomy);
    $vars['category'] = '<a href="/wishes/' . strtolower($category->name) . '">' . $category->name . '</a>';
    // Fix tags to show only tags
    unset($node->taxonomy[$category->tid]);
    if (module_exists('taxonomy')) {
        $terms = taxonomy_link('taxonomy terms', $node);
        $vars['terms'] = theme('links', $terms);
    }
}
function _scratchy_theme_forum($node, $teaser, $page)
{
    $parents = taxonomy_get_parents_all($node->tid);
    $breadcrumb = array();
    $breadcrumb[] = l('Home', '');
    $breadcrumb[] = l('Forums', 'forum');
    if ($parents) {
        $parents = array_reverse($parents);
        foreach ($parents as $p) {
            if ($p->tid == $tid) {
                $title = $p->name;
            } else {
                $breadcrumb[] = l($p->name, 'forum/' . $p->tid);
            }
        }
    }
    drupal_set_breadcrumb($breadcrumb);
    $output = '<div class="node' . (!$node->status ? ' unpublished' : '') . ($node->sticky && !$page ? ' sticky' : '') . '">
  <div class="boxtop">
    <div class="bc ctr"></div>
    <div class="bc ctl"></div>
  </div>
  <div class="boxcontent">
    <div class="boxtitle' . ($node->sticky && !$page ? '-sticky' : '') . '">
      <h1>' . ($teaser ? l($node->title, "node/{$node->nid}") : check_plain($node->title)) . '</h1>
    </div>
    <div class="subboxcontent">';
    // Removed for now.  I SHALL RETURN!
    /*if ($tabs = theme('menu_local_tasks')) {
        $output .= $tabs;
      }*/
    $output .= '<div class="content">';
    if ($teaser && $node->teaser) {
        $output .= $node->teaser;
    } else {
        $output .= $node->body;
    }
    $output .= '</div>';
    if (theme_get_setting("toggle_node_info_{$node->type}")) {
        $submitted['node_submitted'] = array('title' => t("By !author at @date", array('!author' => theme('username', $node), '@date' => format_date($node->created, 'small'))), 'html' => TRUE);
    } else {
        $submitted['node_submitted'] = array();
    }
    $terms = array();
    if (module_exists('taxonomy')) {
        $terms = taxonomy_link("taxonomy terms", $node);
    }
    $links = array_merge($submitted, $terms);
    if ($node->links) {
        $links = array_merge($links, $node->links);
    }
    if (count($links)) {
        $output .= '<div class="links">' . theme('links', $links, array('class' => 'links inline')) . "</div>\n";
    }
    $output .= '</div>
  </div>
  <div class="boxbtm">
    <div class="bc cbr"></div>
    <div class="bc cbl"></div>
  </div>
</div>';
    return $output;
}
/**
 * Override or insert variables into the node templates.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered ("node" in this case.)
 */
function vojo_generic_preprocess_node(&$vars, $hook)
{
    if (module_exists('uploadterm') && module_exists('taxonomy_image')) {
        // media terms
        $term_image_links = array();
        foreach ($vocabulary[variable_get('uploadterm_vocabulary', 0)] as $term) {
            $term_image_links[] = l(taxonomy_image_display($term['tid']), $term['path'], array('html' => TRUE));
            // can add size here
        }
        $vars['mediaterms'] = theme('item_list', $term_image_links, NULL, 'ul', array('class' => 'links inline media'));
    }
    // Keep term links sepearate from other node links. No need to display other links twice.
    $vars['taxonomy'] = taxonomy_link('taxonomy terms', $vars['node']);
    unset($vars['taxonomy']['comment_add']);
    unset($vars['taxonomy']['sms_sendtophone']);
    $vars['terms'] = theme('links', $vars['taxonomy'], array('class' => 'inline links'));
}
示例#4
0
function lean_preprocess_node_default(&$vars)
{
    /**
     * load usual node stuff
     */
    drupal_add_css(path_to_theme() . '/css/node.css', 'theme');
    // Format nice blog calendar style dates
    if ($vars['page']) {
        $vars['blog_date'] = _lean_make_blog_date($vars['node']->created);
    } else {
        $vars['blog_date'] = _lean_make_blog_date($vars['node']->created, 'node/' . $vars['node']->nid);
    }
    // embedded video
    if ($vars['page'] && $vars['node']->field_embedded_video[0]['value']) {
        $vars['embedded_video'] = views_embed_view('embedded_video', 'block_1', $vars['node']->nid);
    }
    // fullwidth image
    if ($vars['page'] && $vars['node']->field_fullwidth_image[0]['value']) {
        $vars['fullwidth_image'] = views_embed_view('embedded_video', 'block_2', $vars['node']->nid);
    }
    if ($vars['page'] && $vars['node']->field_fullwidth_image_upload[0]['fid']) {
        $vars['fullwidth_image'] = views_embed_view('embedded_video', 'block_3', $vars['node']->nid);
    }
    // Remove Sections from terms
    foreach ($vars['node']->taxonomy as $key => $value) {
        if ($value->name == 'Life' || $value->name == 'Geek') {
            unset($vars['node']->taxonomy[$key]);
            $vars['node']->node_section = $value->name;
        }
    }
    $vars['terms'] = theme('links', taxonomy_link('taxonomy terms', $vars['node']));
}