Cách nào để dẹp cái Post By trong trang page

Events happening in the community are now at Drupal community events on www.drupal.org.
squallleonhart81's picture

mình tạo page nhưng ko thích cái post by...-date...., có bác nào chỉ giúp cách dẹp nó không.

Comments

Có cách đơn giản là

tquoc229's picture

Có cách đơn giản là bạn vào Theme setting, trong đó cho phép bạn chọn loại node type muốn bỏ 'post by'. Cách phức tạp hơn là bỏ biến $submitted trong file node.tpl.php (lời khuyên là ko nên dùng cách này).

thanks

squallleonhart81's picture

thanks bạn reply, cách 1 áp dụng cho 1 số themes nó cho phép mình bỏ display post, còn cách 2 thì quả thật ko dám thử ^__^

Để bỏ theo một số

thehong's picture

Để bỏ theo một số điều kiện nhất định thì định nghĩa thêm hàm THEME_preprocess_node trong template.php của theme.

--
Only local images are allowed.

Good place to hire Drupal experts

function

squallleonhart81's picture

function phptemplate_preprocess_node(&$vars) {
// Build array of handy node classes
$node_classes = array();
$node_classes[] = $vars['zebra']; // Node is odd or even
$node_classes[] = (!$vars['node']->status) ? 'node-unpublished' : ''; // Node is unpublished
$node_classes[] = ($vars['sticky']) ? 'sticky' : ''; // Node is sticky
$node_classes[] = (isset($vars['node']->teaser)) ? 'teaser' : 'full-node'; // Node is teaser or full-node
$node_classes[] = 'node-type-'. $vars['node']->type; // Node is type-x, e.g., node-type-page
$node_classes = array_filter($node_classes); // Remove empty elements
$vars['node_classes'] = implode(' ', $node_classes); // Implode class list with spaces

// Add node_bottom region content
$vars['node_bottom'] = theme('blocks', 'node_bottom');

// Node Theme Settings

// Date & author
$date = t('Posted ') . format_date($vars['node']->created, 'medium'); // Format date as small, medium, or large
$author = theme('username', $vars['node']);
$author_only_separator = t('Posted by ');
$author_date_separator = t(' by ');
$submitted_by_content_type = (theme_get_setting('submitted_by_enable_content_type') == 1) ? $vars['node']->type : 'default';
$date_setting = (theme_get_setting('submitted_by_date_'. $submitted_by_content_type) == 1);
$author_setting = (theme_get_setting('submitted_by_author_'. $submitted_by_content_type) == 1);
$author_separator = ($date_setting) ? $author_date_separator : $author_only_separator;
$date_author = ($date_setting) ? $date : '';
$date_author .= ($author_setting) ? $author_separator . $author : '';
$vars['submitted'] = $date_author;

// Taxonomy
$taxonomy_content_type = (theme_get_setting('taxonomy_enable_content_type') == 1) ? $vars['node']->type : 'default';
$taxonomy_display = theme_get_setting('taxonomy_display_'. $taxonomy_content_type);
$taxonomy_format = theme_get_setting('taxonomy_format_'. $taxonomy_content_type);
if ((module_exists('taxonomy')) && ($taxonomy_display == 'all' || ($taxonomy_display == 'only' && $vars['page']))) {
$vocabularies = taxonomy_get_vocabularies($vars['node']->type);
$output = '';
$term_delimiter = ', ';
foreach ($vocabularies as $vocabulary) {
if (theme_get_setting('taxonomy_vocab_hide_'. $taxonomy_content_type .'_'. $vocabulary->vid) != 1) {
$terms = taxonomy_node_get_terms_by_vocabulary($vars['node'], $vocabulary->vid);
if ($terms) {
$term_items = '';
foreach ($terms as $term) { // Build vocabulary term items
$term_link = l($term->name, taxonomy_term_path($term), array('attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description))));
$term_items .= '

  • '. $term_link . $term_delimiter .'
  • ';
    }
    if ($taxonomy_format == 'vocab') { // Add vocabulary labels if separate
    $output .= '

  • vid .'">'. $vocabulary->name .':
    • ';
      $output .= substr_replace($term_items, '

      ', -(strlen($term_delimiter) + 5)) .'

    ';
    }
    else {
    $output .= $term_items;
    }
    }
    }
    }
    if ($output != '') {
    $output = ($taxonomy_format == 'list') ? substr_replace($output, '

    ', -(strlen($term_delimiter) + 5)) : $output;
    $output = '

      '. $output .'

    ';
    }
    $vars['terms'] = $output;
    }
    else {
    $vars['terms'] = '';
    }

    // Node Links
    if (isset($vars['node']->links['node_read_more'])) {
    $node_content_type = (theme_get_setting('readmore_enable_content_type') == 1) ? $vars['node']->type : 'default';
    $vars['node']->links['node_read_more'] = array(
    'title' => themesettings_link(
    theme_get_setting('readmore_prefix
    '. $node_content_type),
    theme_get_setting('readmore_suffix_'. $node_content_type),
    t(theme_get_setting('readmore_'. $node_content_type)),
    'node/'. $vars['node']->nid,
    array(
    'attributes' => array('title' => t(theme_get_setting('readmore_title_'. $node_content_type))),
    'query' => NULL, 'fragment' => NULL, 'absolute' => FALSE, 'html' => TRUE
    )
    ),
    'attributes' => array('class' => 'readmore-item'),
    'html' => TRUE,
    );
    }
    if (isset($vars['node']->links['comment_add'])) {
    $node_content_type = (theme_get_setting('comment_enable_content_type') == 1) ? $vars['node']->type : 'default';
    if ($vars['teaser']) {
    $vars['node']->links['comment_add'] = array(
    'title' => themesettings_link(
    theme_get_setting('comment_add_prefix
    '. $node_content_type),
    theme_get_setting('comment_add_suffix_'. $node_content_type),
    t(theme_get_setting('comment_add_'. $node_content_type)),
    "comment/reply/".$vars['node']->nid,
    array(
    'attributes' => array('title' => t(theme_get_setting('comment_add_title_'. $node_content_type))),
    'query' => NULL, 'fragment' => 'comment-form', 'absolute' => FALSE, 'html' => TRUE
    )
    ),
    'attributes' => array('class' => 'comment-add-item'),
    'html' => TRUE,
    );
    }
    else {
    $vars['node']->links['comment_add'] = array(
    'title' => themesettings_link(
    theme_get_setting('comment_node_prefix
    '. $node_content_type),
    theme_get_setting('comment_node_suffix_'. $node_content_type),
    t(theme_get_setting('comment_node_'. $node_content_type)),
    "comment/reply/".$vars['node']->nid,
    array(
    'attributes' => array('title' => t(theme_get_setting('comment_node_title_'. $node_content_type))),
    'query' => NULL, 'fragment' => 'comment-form', 'absolute' => FALSE, 'html' => TRUE
    )
    ),
    'attributes' => array('class' => 'comment-node-item'),
    'html' => TRUE,
    );
    }
    }
    if (isset($vars['node']->links['comment_new_comments'])) {
    $node_content_type = (theme_get_setting('comment_enable_content_type') == 1) ? $vars['node']->type : 'default';
    $vars['node']->links['comment_new_comments'] = array(
    'title' => themesettings_link(
    theme_get_setting('comment_new_prefix
    '. $node_content_type),
    theme_get_setting('comment_new_suffix_'. $node_content_type),
    format_plural(
    comment_num_new($vars['node']->nid),
    t(theme_get_setting('comment_new_singular_'. $node_content_type)),
    t(theme_get_setting('comment_new_plural_'. $node_content_type))
    ),
    "node/".$vars['node']->nid,
    array(
    'attributes' => array('title' => t(theme_get_setting('comment_new_title_'. $node_content_type))),
    'query' => NULL, 'fragment' => 'new', 'absolute' => FALSE, 'html' => TRUE
    )
    ),
    'attributes' => array('class' => 'comment-new-item'),
    'html' => TRUE,
    );
    }
    if (isset($vars['node']->links['comment_comments'])) {
    $node_content_type = (theme_get_setting('comment_enable_content_type') == 1) ? $vars['node']->type : 'default';
    $vars['node']->links['comment_comments'] = array(
    'title' => themesettings_link(
    theme_get_setting('comment_prefix
    '. $node_content_type),
    theme_get_setting('comment_suffix_'. $node_content_type),
    format_plural(
    comment_num_all($vars['node']->nid),
    t(theme_get_setting('comment_singular_'. $node_content_type)),
    t(theme_get_setting('comment_plural_'. $node_content_type))
    ),
    "node/".$vars['node']->nid,
    array(
    'attributes' => array('title' => t(theme_get_setting('comment_title_'. $node_content_type))),
    'query' => NULL, 'fragment' => 'comments', 'absolute' => FALSE, 'html' => TRUE
    )
    ),
    'attributes' => array('class' => 'comment-item'),
    'html' => TRUE,
    );
    }
    $vars['links'] = theme('links', $vars['node']->links, array('class' => 'links inline'));
    }
    hàm này của theme acquia_slate còn mình thì xài themes clear_dark :D sửa cái code từ acquia_slate qua clear_dark thì bó chíu ^__^

    Thứ nhất bạn vào

    cuxi's picture
    • Cách thứ hai bạn tạo view cho node:
      với path node/%
      add các trường muốn hiển thị khi bạn click full node

    Tran Tan
    Tel : 0905 403 723
    http://baogame.vn/
    http://Bienhoa.vn/

    Tùy chỉnh theme là good nhất!

    tvazone's picture

    Cái này có thể tùy chỉnh theme là good nhất.
    Chỉnh: node-type.tpl.php
    themename_preprocess_node(&$vars)

    Em mới vào chưa biết cách làm

    dinhvioto's picture

    Em mới tham gia chưa biết cách thực hiện. Cám ơn các bác đã chia sẻ kinh nghiệm
    http://dinhvixemayoto.com
    http://dinhvixemayoto.com/thiet-bi-dinh-vi-o-to-gia-re