前面,我们把 $task 设置为 philosopherbios_pick_theme。现在,我们需要让Drupal 安装程序知道我们添加了另一项任务。这是用philosopherbios_profile_task_list() 做到的,安装程序将查找这一回调函数:
/** * List of custom tasks. This is a callback that * the installer expects. */ function philosopherbios_profile_task_list() { return array( 'philosopherbios_pick_theme' => st('Choose Theme'), ); }
这个函数很简单。它返回一个关联数组,任务名称为 key,而一个用户友好的简短描述为 value。
因为 philosopherbios_profile_tasks() 的实际回调机制并没有使用这个任务,那么这个函数的作用又是什么呢?实际上,它主要的用途是给用户显示进度信息:

图 9-5
在上面的截屏中,我们可以看到信息是如何显示的。这个列表是在安装过程的早期生成的,随着安装程序不断进展,任务不断完成,显示信息也会不断更新以表明进度。
完成任务注册以后,我们把关注的焦点转向显示给用户的表单。
评论
发表新评论