<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 431,  comments - 344,  trackbacks - 0
    1Understanding How Blocks Are Themed

    During a page request, the theme system will ask the block system to return a list of blocks for

    each region. It does this when generating the variables to send to the page template (usually

    page.tpl.php). To gather the themed blocks for the left and right sidebars, Drupal executes the

    following:

    $sidebar_left = theme('blocks', 'left');

    $sidebar_right = theme('blocks', 'right');

    // And any other regions exposed by hook_regions().

    You might remember that theme('blocks') is actually a call to theme_blocks(). Here’s what theme_blocks() actually does:

    function theme_blocks($region) {

    $output = '';

    if ($list = block_list($region)) {

    foreach ($list as $key => $block) {

    $output .= theme('block', $block);

    }

    }

    return $output;

    }

    2Using the Block Hook

    function hook_block($op = 'list', $delta = 0, $edit = array())

    <?php

    // $Id$

    /**

     * @file

     * Implements various blocks to improve pending content workflow.

     */

     

    /**

     * Implementation of hook_block().

     */

    function approval_block($op = 'list', $delta = 0, $edit = array()) {

     switch ($op) {

        case 'list':

          $blocks[0]['info'] = t('Pending comments');

          $blocks[1]['info'] = t('Unpublished nodes');

          return $blocks;

        case 'configure':

          // Only in block 0 (the Pending comments block) can one

          // set the number of comments to display.

          if ($delta == 0) {

            $form['approval_block_num_posts'] = array(

              '#type' => 'textfield',

              '#title' => t('Number of pending comments to display'),

              '#default_value' => variable_get('approval_block_num_posts', 5),

            );

          }

          return $form;

        case 'save':

          if ($delta == 0) {

            variable_set('approval_block_num_posts', (int) $edit['approval_block_num_posts']);

          }

          break;

        case 'view':

          if ($delta == 0 &&user_access('administer comments')) {

            // Retrieve the number of pending comments to display that

            // we saved earlier in the 'save' op, defaulting to 5.

            $num_posts = variable_get('approval_block_num_posts', 5);

            // Query the database for unpublished comments.

            $result = db_query_range('SELECT c.* FROM {comments} c WHERE c.status = %d ORDER BY c.timestamp', COMMENT_NOT_PUBLISHED, 0, $num_posts);

            // Preserve our current location so user can return after editing.

            $destination = drupal_get_destination();

            $items = array();

            while ($comment = db_fetch_object($result)) {

              $items[] = l($comment->subject, 'node/'. $comment->nid, array(), NULL, 'comment-'. $comment->cid). ' '. l(t('[edit]'), 'comment/edit/'. $comment->cid, array(), $destination);

            }

            $block['subject'] = t('Pending comments');

            // We theme our array of links as an unordered list.

            $block['content'] = theme('item_list', $items);

          }

          elseif ($delta == 1 && user_access('administer nodes')) {

            // Query the database for the 5 most recent unpublished nodes.

            // Unpublished nodes have their status column set to 0.

            $result = db_query_range('SELECT title, nid FROM {node} WHERE status = 0 ORDER BY changed DESC', 0, 5);

            $destination = drupal_get_destination();

            while ($node = db_fetch_object($result)) {

              $items[] = l($node->title, 'node/'. $node->nid). ' '. l(t('[edit]'), 'node/'. $node->nid .'/edit', array(), $destination);

            }

            $block['subject'] = t('Unpublished nodes');

            // We theme our array of links as an unordered list.

            $block['content'] = theme('item_list', $items);

          }

          return $block;

     }   

    }

    drupal_get_destination()

    This function remembers the page you were on before you submitted a form, so after you update the comment form to publish or delete a comment, you’ll be automatically redirected from whence you came.

    posted on 2007-12-04 11:50 周銳 閱讀(229) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): PHP
    主站蜘蛛池模板: 精品国产免费一区二区| 国产成人久久AV免费| 日韩在线免费电影| 亚洲国产视频久久| 无码国产精品一区二区免费虚拟VR| 人人狠狠综合久久亚洲88| 99视频在线免费观看| 亚洲精品无码成人AAA片| 国产免费拔擦拔擦8X高清在线人| 亚洲精品你懂的在线观看| A级毛片高清免费视频在线播放| 亚洲AV无码专区国产乱码4SE| 一级特黄aa毛片免费观看| 亚洲黄色网站视频| 国产精品69白浆在线观看免费| 国产精品亚洲一区二区麻豆| 韩国18福利视频免费观看| 人人爽人人爽人人片av免费| 亚洲精品无码av人在线观看| 最新黄色免费网站| 亚洲国产精品ⅴa在线观看| 亚洲AV无码一区二区三区人| 无码高潮少妇毛多水多水免费| 亚洲a无码综合a国产av中文| 国产国拍亚洲精品福利| 最近中文字幕国语免费完整| 亚洲日本人成中文字幕| 免费成人黄色大片| 毛片在线全部免费观看| 亚洲国产成AV人天堂无码| 国产成人一区二区三区免费视频| 国产无遮挡色视频免费观看性色| 亚洲AV无码乱码在线观看富二代| 免费无码黄十八禁网站在线观看| 国产成人亚洲综合无| 久久久久亚洲AV成人无码 | 精品无码国产污污污免费网站国产| 亚洲国产精品乱码一区二区| 啦啦啦高清视频在线观看免费 | 亚洲av日韩av综合| 久久影院亚洲一区|