zoukankan      html  css  js  c++  java
  • Drupal进度条

    Drupal有一个内置的百分比进度条显示操作进度的工具batch.

    使用方式如下:

    batch_set(batch_example_batch_1());

    batch_process(
    'redirect_page.php');

    function batch_example_batch_1() {

        
    for ($i = 0$i<100$i++) {
            
    $operations[] = array('batch_example_op_1', array($nid));
        }
        
    $batch = array(
                
    'operations' => $operations,
                
    'finished' => 'batch_example_finished',
        );
        
    return $batch;
    }

    function batch_example_op_1($nid, &$context) {

        do_something();

        
    // Store some result for post-processing in the finished callback.
        $context['results'][] = "do something";

        
    // Optional message displayed under the progressbar.
        $context['message'= t('Loading @title', array('@title' => $node->title));

    }

    function batch_example_finished($success, $results, $operations) {
        
    if ($success) {
            
    $message = count($results. ' processed.';
        }
        
    else {
            
    $error_operation = reset($operations);
            
    $message = 'An error occurred while processing ' . $error_operation[0. ' with arguments :' . print_r($error_operation[0], TRUE);
        }
        drupal_set_message(
    $message);


  • 相关阅读:
    shell基础之更改IP
    shell基础之if语句
    shell基础之变量及表达式
    shell基础之shell相关概念
    shell基础之bus实战(if 练习)
    shell基础之pxe批量部署
    shell基础之编译安装nginx
    Razor视图引擎基础语法
    EF三层
    EF简单增删改查
  • 原文地址:https://www.cnblogs.com/catcat811/p/2097984.html
Copyright © 2011-2022 走看看